Skip to content

Commit

Permalink
setting exit status for unknown command
Browse files Browse the repository at this point in the history
  • Loading branch information
sombriks committed May 4, 2024
1 parent accf27c commit 4d841a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/rife/bld/BuildExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ public boolean executeCommand(String command)
new HelpOperation(this, arguments()).executePrintOverviewHelp();
System.err.println();
System.err.println("ERROR: unknown command '" + command + "'");
exitStatus(1);
return false;
}
return true;
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/rife/bld/TestProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,16 @@ void testCommandMatch()
try {
var result = new StringBuilder();
var project = new CustomProjectLambda(tmp, result);
project.execute(new String[]{"ne2", "nc2", "n2"});
var status = project.execute(new String[]{"ne2", "nc2", "n2"});
assertEquals("newcommand2" +
"newcommand2" +
"newcommand2", result.toString());
assertEquals(0, status, "Exit status should be 0");

result = new StringBuilder();
project.execute(new String[]{"c"});
status = project.execute(new String[]{"c"});
assertEquals("", result.toString());
assertEquals(1, status, "Exit status should be 1");
} finally {
FileUtils.deleteDirectory(tmp);
}
Expand Down

0 comments on commit 4d841a7

Please sign in to comment.