From 4d841a7c7238c553b1a698ba5d598cf5a76a9942 Mon Sep 17 00:00:00 2001 From: Leonardo Silveira Date: Sat, 4 May 2024 18:44:18 -0300 Subject: [PATCH] setting exit status for unknown command --- src/main/java/rife/bld/BuildExecutor.java | 1 + src/test/java/rife/bld/TestProject.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/rife/bld/BuildExecutor.java b/src/main/java/rife/bld/BuildExecutor.java index 41eb88e..30a3aa0 100644 --- a/src/main/java/rife/bld/BuildExecutor.java +++ b/src/main/java/rife/bld/BuildExecutor.java @@ -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; diff --git a/src/test/java/rife/bld/TestProject.java b/src/test/java/rife/bld/TestProject.java index cce0c6c..5eb8ce8 100644 --- a/src/test/java/rife/bld/TestProject.java +++ b/src/test/java/rife/bld/TestProject.java @@ -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); }