This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new e05c5485d507 CAMEL-26467: camel-jbang - A file that does not exist
exits with 66 (EX_NOINPUT), not 3 (#28798)
e05c5485d507 is described below
commit e05c5485d507ebf270e817233b50cc2aedfdbb4b
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Nov 1 19:18:08 2026 +0100
CAMEL-26467: camel-jbang - A file that does not exist exits with 66
(EX_NOINPUT), not 3 (#28798)
Exit code 3 (not found) was used both for a name that is not running or
not there, which is the LSB convention (systemctl status gives 3 for a
service that is not running), and for a file or directory that does not
exist, for which 3 is no convention. A file or directory given on the
command line that does not exist, or holds none of the files the command
needs, now exits with 66, EX_NOINPUT from sysexits.h, the standard code
for missing input. 3 stays for integrations, routes, services, plugins,
catalog entries and other names.
camel --help, the description of the cli tool of camel ask, the exit
codes page and the 4.24 upgrade guide list the new code.
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 24 ++++++++++++----------
.../modules/ROOT/pages/camel-jbang-exit-codes.adoc | 17 +++++++++------
.../camel/dsl/jbang/core/commands/AskTools.java | 3 ++-
.../dsl/jbang/core/commands/CamelJBangMain.java | 3 ++-
.../dsl/jbang/core/commands/DependencyRuntime.java | 2 +-
.../dsl/jbang/core/commands/DependencyUpdate.java | 2 +-
.../camel/dsl/jbang/core/commands/Explain.java | 2 +-
.../camel/dsl/jbang/core/commands/Harden.java | 2 +-
.../camel/dsl/jbang/core/commands/Overview.java | 2 +-
.../apache/camel/dsl/jbang/core/commands/Run.java | 4 ++--
.../jbang/core/commands/TransformDataWeave.java | 4 ++--
.../core/commands/action/ActionBaseCommand.java | 4 ++--
.../commands/action/CamelRouteStructureAction.java | 2 +-
.../commands/action/EvalExpressionCommand.java | 2 +-
.../commands/action/TransformMessageAction.java | 4 ++--
.../CliExecutionExceptionHandler.java | 6 +++---
.../dsl/jbang/core/commands/update/UpdateRun.java | 2 +-
.../camel/dsl/jbang/core/common/CliException.java | 10 ++++++++-
.../camel/dsl/jbang/core/common/CliExitCode.java | 11 ++++++++--
.../core/commands/CommandInputErrorsTest.java | 17 +++++++--------
.../jbang/core/commands/DependencyRuntimeTest.java | 3 ++-
.../jbang/core/commands/ExitCodeContractTest.java | 5 +++--
.../camel/dsl/jbang/core/commands/ExplainTest.java | 2 +-
.../dsl/jbang/core/commands/OverviewTest.java | 2 +-
.../core/commands/TransformDataWeaveTest.java | 3 ++-
.../jbang/core/commands/TransformRouteTest.java | 5 +++--
.../CamelRouteDiagramActionDispatchTest.java | 4 ++--
.../CamelRouteDiagramActionMultiFileTest.java | 4 ++--
.../action/CamelRouteTopologyActionTest.java | 4 ++--
.../commands/action/RouteActionJavaSourceTest.java | 2 +-
.../action/TransformMessageActionTest.java | 2 +-
.../jbang/core/commands/update/UpdateRunTest.java | 2 +-
.../core/commands/generate/CodeRestGenerator.java | 2 +-
.../validate/PropertiesValidateCommand.java | 2 +-
.../commands/validate/YamlValidateCommand.java | 2 +-
.../core/commands/validate/ValidateJsonTest.java | 6 +++---
.../apache/camel/dsl/jbang/run/RunPipeline.java | 6 +++---
37 files changed, 104 insertions(+), 75 deletions(-)
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 55384f7e25f2..b50ad720d318 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -969,27 +969,29 @@ PEM handling is also now explicitly UTF-8 rather than the
platform default chars
=== camel-jbang - exit codes, and errors on stderr
The Camel CLI has a documented set of exit codes (see
xref:camel-jbang-exit-codes.adoc[Exit Codes and Output]):
-`0` success, `1` failed, `2` usage error, `3` not found, `70` internal error
and `124` timed out.
+`0` success, `1` failed, `2` usage error, `3` not found, `66` file not found,
`70` internal error and `124` timed out.
A script that checks the exit code of a command must take these changes into
account:
* A command that ends with an unexpected exception exits with `70` instead of
`1`, and prints `ERROR:`, the message and
the stack trace on stderr. Add `--verbose` or set `CAMEL_CLI_DEBUG=true` to
print the stack trace of other errors too.
-* Commands that exited with `255` now exit with `1`, `2`, `3` or `124`: `camel
bind`, `camel debug`,
+* Commands that exited with `255` now exit with `1`, `2`, `3`, `66` or `124`:
`camel bind`, `camel debug`,
`camel dependency update`, `camel eval expression`, `camel infra log`,
`camel transform message` and `camel update run`.
`camel debug` exits with the exit code of the debugged integration when it
ends.
* `camel semantic` exits with `124` instead of `4` when the integration does
not reply in time.
* `camel generate schema` exits with `2` for an empty argument, `3` when the
class is not found, `1` when the schema
cannot be generated and `70` for an unexpected error, instead of `4`, `2`,
`3` and `4`.
-* `camel transform dataweave` exits with `2` without `--input` or
`--expression`, and with `3` when the input path does
+* `camel transform dataweave` exits with `2` without `--input` or
`--expression`, and with `66` when the input path does
not exist or holds no `.dwl` files, instead of `1`.
* `camel cmd sql` exits with `124` instead of `1` when the query does not
answer in time.
* A source file of `camel cmd route-diagram`, `camel cmd route-structure` and
`camel cmd route-topology` that does not
- exist exits with `3` instead of `1`. The parts of a Java route the parser
could not read are printed as a warning on
+ exist exits with `66` instead of `1`. The parts of a Java route the parser
could not read are printed as a warning on
stderr (also with `--json`, which lists them in `unread` as before).
-* A file or a name that does not exist exits with `3` instead of `1`: a source
file or `--source-dir` of `camel run`, the
- route file of `camel explain` and `camel harden` (checked before the LLM is
contacted), the `pom.xml` of
- `camel dependency runtime`, the Kamelet of `camel init --from-kamelet`, the
service of `camel infra run`, the key of
- `camel config get`, the name given to `camel doc`, and the plugin of `camel
plugin delete`.
+* A file or directory that does not exist exits with `66` instead of `1`: a
source file or `--source-dir` of
+ `camel run`, the route file of `camel explain` and `camel harden` (checked
before the LLM is contacted), and the
+ `pom.xml` of `camel dependency runtime`.
+* A name that does not exist exits with `3` instead of `1`: the Kamelet of
`camel init --from-kamelet`, the service of
+ `camel infra run`, the key of `camel config get`, the name given to `camel
doc`, and the plugin of
+ `camel plugin delete`.
* `camel cmd memory-leak` and `camel restart` exit with `3` when no running
integration, or more than one, matches the
name. `camel cmd memory-leak` exits with `124` when the integration does not
reply in time.
* `camel init` without a file, or with `--from-kamelet` and a file that is not
a `.kamelet.yaml` file,
@@ -1208,7 +1210,7 @@ or follows, like Enter does.
* `camel run` and `camel dev` with `--max-seconds`, `--max-messages` or
`--max-idle-seconds` exit at the limit also in
dev mode, which stopped the routes and kept running. A limit from the
configuration (`camel.main.durationMax...`)
still only stops the routes in dev mode.
-* A file that does not exist exits with `3` and `File does not exist: <file>`
for every kind of file, before anything is
+* A file that does not exist exits with `66` and `File does not exist: <file>`
for every kind of file, before anything is
printed. Files together with `--source-dir`, and `--background` with a
runtime that does not support it, exit with
`2`.
@@ -1270,7 +1272,7 @@ provider is detected as before.
when it is reached.
* `camel version list` exits with `1` when the versions cannot be downloaded.
`camel version set --reset` removes the
Kamelets version too, and `camel version get` shows a configuration with
only the Kamelets version.
-* `camel validate yaml` and `camel validate properties` with no file to
validate exit with `3`.
+* `camel validate yaml` and `camel validate properties` with no file to
validate exit with `66`.
* `camel doc` looks a name up in the catalog of Camel before it downloads the
Kamelet catalog, so a component is
documented also offline. `camel catalog kamelet` has `--repos`.
* `camel kubernetes logs` exits with `3` when no pod with the label shows up,
and with `1` when reading the log fails.
@@ -4453,7 +4455,7 @@ To find the dependencies, `camel export` boots the
integration silently, as befo
* `--camel-version` is accepted by `camel export` from `camel-launcher` too:
it sets the Camel version of the exported
project. Before, it failed with a usage error.
* `camel export clipboard.yaml` no longer reads the route from the clipboard
when there is no such file: it fails with
- exit code 3 (file not found), as for any other missing file. Save the
content of the clipboard to a file and export
+ exit code 66 (file not found), as for any other missing file. Save the
content of the clipboard to a file and export
that file.
* `camel export --profile=<profile>` boots the integration with that profile
to find the dependencies. Before, it always
booted with the `dev` profile, so a component that only
`application-<profile>.properties` uses was missing from the
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-exit-codes.adoc
b/docs/user-manual/modules/ROOT/pages/camel-jbang-exit-codes.adoc
index fee298b4286a..b3753abb23ec 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-exit-codes.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-exit-codes.adoc
@@ -28,9 +28,13 @@ The exit codes and streams on this page apply from Camel
4.24 onwards.
| `3`
| Not found
-| A file, integration, route, component or service named on the command line
does not exist,
+| An integration, route, component, service or other name given on the command
line is not running or does not exist,
or a name matches more than one running integration.
+| `66`
+| File not found
+| A file or directory given on the command line does not exist, or holds none
of the files the command needs.
+
| `70`
| Internal error
| An unexpected exception, which is most often a bug in Camel. The error is
printed with its stack trace.
@@ -41,9 +45,9 @@ The exit codes and streams on this page apply from Camel 4.24
onwards.
|===
Each code is the one that most tools already use for that meaning: `2` for a
usage error is what picocli and other
-command line parsers use, `3` follows the LSB convention that a service is not
running, `70` is `EX_SOFTWARE` from
-`sysexits.h`, and `124` is what the GNU `timeout` command returns. So a script
or an AI agent can understand a code
-without this page.
+command line parsers use, `3` follows the LSB convention that a service is not
running (as `systemctl status` returns),
+`66` is `EX_NOINPUT` and `70` is `EX_SOFTWARE` from `sysexits.h`, and `124` is
what the GNU `timeout` command returns.
+So a script or an AI agent can understand a code without this page.
`camel --help` lists the exit codes as well.
@@ -156,7 +160,8 @@ The exit code tells a script or an AI agent what to do next:
| `1` | Fix the route, the configuration or the input, then run the command
again.
| `2` | Fix the command line; `camel <command> --help` shows the options.
-| `3` | Check the name or the path; `camel ps` lists the running integrations.
+| `3` | Check the name; `camel ps` lists the running integrations.
+| `66` | Check the path of the file or directory.
| `70` | Do not retry: read the stack trace, and report the error to the Camel
project when it is a bug.
| `124` | Wait, or run the command again with a longer timeout.
|===
@@ -168,7 +173,7 @@ case $? in
0) echo "converted" ;;
1) echo "the script could not be converted" ;;
2) echo "check the options" ;;
- 3) echo "mapping.dwl does not exist" ;;
+ 66) echo "mapping.dwl does not exist" ;;
*) echo "unexpected failure" ;;
esac
----
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/AskTools.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/AskTools.java
index b5e81b494910..9e0aa0ce9da7 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/AskTools.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/AskTools.java
@@ -212,7 +212,8 @@ public class AskTools {
tools.add(new LlmClient.ToolDef(
CLI_EXEC,
"Execute a Camel CLI command, such as 'get route' or 'ps', and
return its exitCode, stdout and stderr as"
- + " JSON (exit code 0 is success, 1 failed, 2 wrong
command line, 3 not found, 124 timed out)."
+ + " JSON (exit code 0 is success, 1 failed, 2 wrong
command line, 3 not found, 66 file not"
+ + " found, 70 internal error, 124 timed out)."
+ " A command that changes something (run, stop,
cmd, infra run, ...) asks the user first; one"
+ " that runs until it is stopped is refused with
the form that returns.",
objectParams(Map.of(
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
index 08052fd08b07..57423abb64ad 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/CamelJBangMain.java
@@ -82,7 +82,8 @@ import picocli.CommandLine.Command;
" 0:Success",
" 1:Failed: the command ran, but the outcome is negative",
" 2:Usage error: invalid option or argument",
- " 3:Not found: no such file, integration, route or service",
+ " 3:Not found: no such integration, route or service",
+ " 66:File not found: no such file or directory",
" 70:Internal error: an unexpected exception",
"124:Timed out: no reply from the integration in time" })
public class CamelJBangMain implements Callable<Integer> {
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntime.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntime.java
index 31329696c685..94d9b6b1a6e4 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntime.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntime.java
@@ -58,7 +58,7 @@ public class DependencyRuntime extends CamelCommand {
// read pom.xml
if (!Files.exists(pomXml)) {
printer().printErr(String.format("Cannot find %s", pomXml));
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
Model model = MavenProjectHelper.loadMavenModel(pomXml);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdate.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdate.java
index 87bda04d17c4..bcd5de328f15 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdate.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyUpdate.java
@@ -92,7 +92,7 @@ public class DependencyUpdate extends DependencyList {
for (Path file : targetFiles) {
if (!Files.exists(file)) {
printer().printErr("Source file does not exist: " + file);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
String name = file.getFileName().toString();
String ext = FileUtil.onlyExt(name, true);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Explain.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Explain.java
index 10d8cdbdf369..4c3d76765440 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Explain.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Explain.java
@@ -158,7 +158,7 @@ public class Explain extends CamelCommand {
for (String file : files) {
if (!Files.exists(Path.of(file))) {
printer().printErr("File not found: " + file);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Harden.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Harden.java
index 63461f1e5382..427ff0da5fdc 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Harden.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Harden.java
@@ -223,7 +223,7 @@ public class Harden extends CamelCommand {
for (String file : files) {
if (!Files.exists(Path.of(file))) {
printer().printErr("File not found: " + file);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Overview.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Overview.java
index 79d9a38df945..e5675c59864f 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Overview.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Overview.java
@@ -134,7 +134,7 @@ public class Overview extends CamelCommand {
}
Path dir = Path.of(directory != null ? directory :
".").toAbsolutePath().normalize();
if (!Files.exists(dir)) {
- throw CliException.notFound("Directory does not exist: " + dir);
+ throw CliException.fileNotFound("Directory does not exist: " +
dir);
}
if (!Files.isDirectory(dir)) {
throw CliException.usage("Not a directory: " + dir);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index 19b4bb2db619..29b6d27bee57 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -347,7 +347,7 @@ public class Run extends CamelCommand {
}
/**
- * Fails a local file that does not exist with exit code 3, before
anything is prepared or printed. Remote files
+ * Fails a local file that does not exist with exit code 66, before
anything is prepared or printed. Remote files
* (such as github: and https:) and wildcards are checked when they are
read.
*/
void checkFilesExist() {
@@ -368,7 +368,7 @@ public class Run extends CamelCommand {
exists = false;
}
if (!exists) {
- throw CliException.notFound("File does not exist: " + path);
+ throw CliException.fileNotFound("File does not exist: " +
path);
}
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeave.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeave.java
index d1762d7b5835..589aeeeb1b5c 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeave.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeave.java
@@ -95,7 +95,7 @@ public class TransformDataWeave extends CamelCommand {
Path inputPath = Path.of(input);
if (!Files.exists(inputPath)) {
printer().printErr("Input path does not exist: " + input);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
List<Path> dwlFiles = new ArrayList<>();
@@ -107,7 +107,7 @@ public class TransformDataWeave extends CamelCommand {
}
if (dwlFiles.isEmpty()) {
printer().printErr("No .dwl files found in: " + input);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
} else {
dwlFiles.add(inputPath);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java
index ff50b86567d9..fdd1f89ff806 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/ActionBaseCommand.java
@@ -250,7 +250,7 @@ abstract class ActionBaseCommand extends CamelCommand {
* @param compile whether to compile Java sources and boot
them, instead of reading them with the parser
* @return the dump location and the instant the dump
started, or {@code null} if the dump failed
* (an error is already printed to the user in
that case)
- * @throws CliException when a source file does not exist (exit code
3)
+ * @throws CliException when a source file does not exist (exit code
66)
*/
protected SourceDump dumpRoutesFromSource(
List<String> sourceFiles, String workDirPrefix, boolean
ignoreLoadingError, boolean compile)
@@ -258,7 +258,7 @@ abstract class ActionBaseCommand extends CamelCommand {
for (String name : sourceFiles) {
File f = new File(name);
if (!f.isFile() || !f.exists()) {
- throw CliException.notFound("File does not exist: " + name);
+ throw CliException.fileNotFound("File does not exist: " +
name);
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteStructureAction.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteStructureAction.java
index 6e6cfba30db3..096e882b7b45 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteStructureAction.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteStructureAction.java
@@ -216,7 +216,7 @@ public class CamelRouteStructureAction extends
ActionBaseCommand {
private JsonObject doCallSource(String name) throws Exception {
File f = new File(name);
if (!f.isFile() || !f.exists()) {
- throw CliException.notFound("File does not exist: " + name);
+ throw CliException.fileNotFound("File does not exist: " + name);
}
// a file of its own, as several commands may run at the same time
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/EvalExpressionCommand.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/EvalExpressionCommand.java
index b501a514402b..78e8c93a41bc 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/EvalExpressionCommand.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/EvalExpressionCommand.java
@@ -108,7 +108,7 @@ public class EvalExpressionCommand extends
ActionWatchCommand {
Path f = Path.of(template.substring(5));
if (!Files.exists(f)) {
printer().printErr("Template file does not exist: " + f);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageAction.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageAction.java
index 7fe757920e36..88ea05911d65 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageAction.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageAction.java
@@ -156,14 +156,14 @@ public class TransformMessageAction extends
ActionWatchCommand {
Path f = Path.of(s);
if (!Files.exists(f)) {
printer().printErr("Source file does not exist: " + f);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
}
if (template != null && template.startsWith("file:")) {
Path f = Path.of(template.substring(5));
if (!Files.exists(f)) {
printer().printErr("Template file does not exist: " + f);
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/exceptionhandler/CliExecutionExceptionHandler.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/exceptionhandler/CliExecutionExceptionHandler.java
index 8ce61ccd9beb..94372c392bc9 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/exceptionhandler/CliExecutionExceptionHandler.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/exceptionhandler/CliExecutionExceptionHandler.java
@@ -39,8 +39,8 @@ import picocli.CommandLine.ParseResult;
* {@link CliExitCode}.
* <p/>
* A {@link CliException} prints its message as one {@code ERROR:} line, and
exits with its code. A file that does not
- * exist exits with {@link CliExitCode#NOT_FOUND}. Any other exception is
unexpected: it prints the error with the stack
- * trace, and exits with {@link CliExitCode#INTERNAL}. With {@code --verbose}
or the environment variable
+ * exist exits with {@link CliExitCode#FILE_NOT_FOUND}. Any other exception is
unexpected: it prints the error with the
+ * stack trace, and exits with {@link CliExitCode#INTERNAL}. With {@code
--verbose} or the environment variable
* {@code CAMEL_CLI_DEBUG=true}, every error prints its stack trace.
* <p/>
* A command in JSON mode ({@code --json}) also prints the error as a JSON
document on stdout, see {@link JsonOutput}.
@@ -95,7 +95,7 @@ public class CliExecutionExceptionHandler implements
IExecutionExceptionHandler,
return CliExitCode.USAGE;
}
if (fileNotFound(ex) != null) {
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
return CliExitCode.INTERNAL;
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRun.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRun.java
index a403143eb819..6e11ede0d0ad 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRun.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRun.java
@@ -68,7 +68,7 @@ public class UpdateRun extends CamelCommand {
if (!Files.isRegularFile(projectDir.resolve("pom.xml"))) {
printer().printErr("No Maven project found in the current
directory: run camel update run in the directory "
+ "with the pom.xml of the project to update");
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
List<String> command = new ArrayList<>();
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliException.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliException.java
index d4dfe3992db5..b76971ddabbd 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliException.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliException.java
@@ -59,12 +59,20 @@ public class CliException extends RuntimeException {
}
/**
- * A file, integration, route, component or service named on the command
line does not exist.
+ * An integration, route, component, service or other name given on the
command line is not running or does not
+ * exist.
*/
public static CliException notFound(String message) {
return new CliException(CliExitCode.NOT_FOUND, message);
}
+ /**
+ * A file or directory given on the command line does not exist.
+ */
+ public static CliException fileNotFound(String message) {
+ return new CliException(CliExitCode.FILE_NOT_FOUND, message);
+ }
+
/**
* The integration did not reply, start or stop in time.
*/
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliExitCode.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliExitCode.java
index c4e3aaca3ec7..30862ee576c5 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliExitCode.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/common/CliExitCode.java
@@ -43,11 +43,18 @@ public final class CliExitCode {
public static final int USAGE = 2;
/**
- * Not found: a file, integration, route, component or service named on
the command line does not exist, or a name
- * matches more than one integration.
+ * Not found: an integration, route, component, service or other name
given on the command line is not running or
+ * does not exist, or a name matches more than one integration. The same
code as {@code systemctl status} gives for
+ * a service that is not running (LSB). A file that does not exist is
{@link #FILE_NOT_FOUND}.
*/
public static final int NOT_FOUND = 3;
+ /**
+ * File not found: a file or directory given on the command line does not
exist, or holds none of the files the
+ * command needs. The code is EX_NOINPUT from sysexits.h.
+ */
+ public static final int FILE_NOT_FOUND = 66;
+
/**
* Internal error: an unexpected exception, which is most often a bug in
Camel. The code is EX_SOFTWARE from
* sysexits.h.
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CommandInputErrorsTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CommandInputErrorsTest.java
index b8538dff3ccc..3fd405f752fa 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CommandInputErrorsTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/CommandInputErrorsTest.java
@@ -39,8 +39,9 @@ import static
org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
/**
- * A command called wrong exits with 2 (usage error), and a file or name that
does not exist exits with 3 (not found).
- * Either way the command prints one ERROR line on stderr, nothing on stdout,
and stops before it does any work.
+ * A command called wrong exits with 2 (usage error), a file that does not
exist exits with 66 (file not found), and a
+ * name that does not exist exits with 3 (not found). Either way the command
prints one ERROR line on stderr, nothing on
+ * stdout, and stops before it does any work.
*/
class CommandInputErrorsTest {
@@ -68,7 +69,7 @@ class CommandInputErrorsTest {
void explainChecksTheFilesBeforeTheLlm() throws Exception {
Path missing = dir.resolve("missing.yaml");
- assertThat(call(new Explain(main),
missing.toString())).isEqualTo(CliExitCode.NOT_FOUND);
+ assertThat(call(new Explain(main),
missing.toString())).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).isEqualTo("ERROR: File not found: " +
missing);
assertThat(printer.getStdout()).isEmpty();
}
@@ -77,7 +78,7 @@ class CommandInputErrorsTest {
void hardenChecksTheFilesBeforeTheLlm() throws Exception {
Path missing = dir.resolve("missing.yaml");
- assertThat(call(new Harden(main),
missing.toString())).isEqualTo(CliExitCode.NOT_FOUND);
+ assertThat(call(new Harden(main),
missing.toString())).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).isEqualTo("ERROR: File not found: " +
missing);
assertThat(printer.getStdout()).isEmpty();
}
@@ -93,7 +94,7 @@ class CommandInputErrorsTest {
void evalExpressionWithAMissingTemplateFile() throws Exception {
Path missing = dir.resolve("missing.txt");
- assertThat(call(new EvalExpressionCommand(main), "--template=file:" +
missing)).isEqualTo(CliExitCode.NOT_FOUND);
+ assertThat(call(new EvalExpressionCommand(main), "--template=file:" +
missing)).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).isEqualTo("ERROR: Template file does
not exist: " + missing);
}
@@ -109,7 +110,7 @@ class CommandInputErrorsTest {
Path missing = dir.resolve("missing.yaml");
assertThat(call(new TransformMessageAction(main), "--body=Hello",
"--source=file:" + missing))
- .isEqualTo(CliExitCode.NOT_FOUND);
+ .isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).isEqualTo("ERROR: Source file does not
exist: " + missing);
}
@@ -126,7 +127,7 @@ class CommandInputErrorsTest {
void dependencyUpdateWithAMissingFile() throws Exception {
Path missing = dir.resolve("missing/pom.xml");
- assertThat(call(new DependencyUpdate(main),
missing.toString())).isEqualTo(CliExitCode.NOT_FOUND);
+ assertThat(call(new DependencyUpdate(main),
missing.toString())).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).isEqualTo("ERROR: Source file does not
exist: " + missing);
}
@@ -159,7 +160,7 @@ class CommandInputErrorsTest {
assertThatThrownBy(() -> call(new Run(main), file))
.isInstanceOf(CliException.class)
.hasMessage("File does not exist: " + file.replace("file:",
""))
- .extracting(e -> ((CliException)
e).getExitCode()).isEqualTo(CliExitCode.NOT_FOUND);
+ .extracting(e -> ((CliException)
e).getExitCode()).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getOutput()).isEmpty();
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntimeTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntimeTest.java
index 21974c020949..cd2ff9f3ed10 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntimeTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/DependencyRuntimeTest.java
@@ -21,6 +21,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
+import org.apache.camel.dsl.jbang.core.common.CliExitCode;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -74,7 +75,7 @@ class DependencyRuntimeTest extends
CamelCommandBaseTestSupport {
command.pomXml = tempDir.toPath().resolve("non-existing/pom.xml");
int exit = command.doCall();
- assertEquals(3, exit);
+ assertEquals(CliExitCode.FILE_NOT_FOUND, exit);
assertTrue(printer.getStderr().startsWith("ERROR: Cannot find "),
printer.getStderr());
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExitCodeContractTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExitCodeContractTest.java
index 0b4e3d2484b0..16813e1cdf64 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExitCodeContractTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExitCodeContractTest.java
@@ -80,7 +80,8 @@ class ExitCodeContractTest {
@Test
void cliExceptionCodesArePassedOn() {
for (int code : new int[] {
- CliExitCode.FAILURE, CliExitCode.USAGE, CliExitCode.NOT_FOUND,
CliExitCode.TIMEOUT }) {
+ CliExitCode.FAILURE, CliExitCode.USAGE, CliExitCode.NOT_FOUND,
CliExitCode.FILE_NOT_FOUND,
+ CliExitCode.TIMEOUT }) {
assertThat(run("test-fail", "--code=" + code)).isEqualTo(code);
}
}
@@ -113,7 +114,7 @@ class ExitCodeContractTest {
@Test
void missingFileIsNotFound() {
- assertThat(run("test-missing-file")).isEqualTo(CliExitCode.NOT_FOUND);
+
assertThat(run("test-missing-file")).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).isEqualTo("ERROR: File not found:
routes/missing.yaml");
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExplainTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExplainTest.java
index b3faf769da6d..bbb048baadac 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExplainTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExplainTest.java
@@ -137,7 +137,7 @@ class ExplainTest extends CamelCommandBaseTestSupport {
@Test
void aFileThatDoesNotExistIsNotFound() throws Exception {
-
assertThat(command(dir.resolve("nope.yaml").toString()).doCall()).isEqualTo(CliExitCode.NOT_FOUND);
+
assertThat(command(dir.resolve("nope.yaml").toString()).doCall()).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).contains("File not found: ");
assertThat(llm.lastRequest()).isNull();
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/OverviewTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/OverviewTest.java
index 5f3f32ceea67..e7db59f1c8eb 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/OverviewTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/OverviewTest.java
@@ -117,7 +117,7 @@ class OverviewTest extends CamelCommandBaseTestSupport {
assertThatThrownBy(command::doCall)
.isInstanceOfSatisfying(CliException.class,
- e ->
assertThat(e.getExitCode()).isEqualTo(CliExitCode.NOT_FOUND));
+ e ->
assertThat(e.getExitCode()).isEqualTo(CliExitCode.FILE_NOT_FOUND));
}
@Test
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeaveTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeaveTest.java
index c0c5a9a5a651..4532658545cb 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeaveTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformDataWeaveTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.dsl.jbang.core.commands;
import java.nio.file.Files;
import java.nio.file.Path;
+import org.apache.camel.dsl.jbang.core.common.CliExitCode;
import org.apache.camel.dsl.jbang.core.common.CommandLineTestHelper;
import org.apache.camel.dsl.jbang.run.common.StringPrinter;
import org.junit.jupiter.api.Test;
@@ -104,7 +105,7 @@ class TransformDataWeaveTest {
CommandLineTestHelper.parse(cmd, "--input=" +
dir.resolve("missing.dwl"));
int exit = cmd.doCall();
- assertThat(exit).isEqualTo(3);
+ assertThat(exit).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).startsWith("ERROR: Input path does not
exist:");
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformRouteTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformRouteTest.java
index 90bbb69308d5..4c0d9c9cd670 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformRouteTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/TransformRouteTest.java
@@ -124,8 +124,9 @@ class TransformRouteTest extends
CamelCommandBaseTestSupport {
Throwable e = catchThrowable(command::doCall);
assertThat(e).isInstanceOf(NoSuchFileException.class);
- // which the CLI ends with exit code 3
- assertThat(new CliExecutionExceptionHandler(new
CamelJBangMain()).getExitCode(e)).isEqualTo(CliExitCode.NOT_FOUND);
+ // which the CLI ends with exit code 66
+ assertThat(new CliExecutionExceptionHandler(new
CamelJBangMain()).getExitCode(e))
+ .isEqualTo(CliExitCode.FILE_NOT_FOUND);
}
@Test
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionDispatchTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionDispatchTest.java
index f312e8d8bc73..7287c43afd4a 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionDispatchTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionDispatchTest.java
@@ -50,7 +50,7 @@ class CamelRouteDiagramActionDispatchTest extends
ActionCommandTestSupport {
CliException e = assertThrows(CliException.class, () ->
callWatchWithSingleProcess(command));
- assertEquals(CliExitCode.NOT_FOUND, e.getExitCode());
+ assertEquals(CliExitCode.FILE_NOT_FOUND, e.getExitCode());
assertEquals("File does not exist: doesNotExist", e.getMessage(),
"should report the missing source file");
}
@@ -66,7 +66,7 @@ class CamelRouteDiagramActionDispatchTest extends
ActionCommandTestSupport {
CliException e = assertThrows(CliException.class,
command::doWatchCall);
- assertEquals(CliExitCode.NOT_FOUND, e.getExitCode());
+ assertEquals(CliExitCode.FILE_NOT_FOUND, e.getExitCode());
assertEquals("File does not exist: route1", e.getMessage(),
"with 2+ file args, dispatch must go straight to source-file
handling and skip the "
+
"running-integration lookup entirely");
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionMultiFileTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionMultiFileTest.java
index 70df6fae598a..9214a02f08f6 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionMultiFileTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteDiagramActionMultiFileTest.java
@@ -55,11 +55,11 @@ class CamelRouteDiagramActionMultiFileTest {
StringPrinter printer = new StringPrinter();
CamelRouteDiagramAction command = new CamelRouteDiagramAction(new
CamelJBangMain().withPrinter(printer));
- // the missing file ends the command (exit code 3) before Camel is
booted
+ // the missing file ends the command (exit code 66) before Camel is
booted
CliException e = assertThrows(CliException.class,
() -> command.doCallSource(List.of(existing.toString(),
"does-not-exist.yaml")));
- assertEquals(CliExitCode.NOT_FOUND, e.getExitCode());
+ assertEquals(CliExitCode.FILE_NOT_FOUND, e.getExitCode());
assertEquals("File does not exist: does-not-exist.yaml",
e.getMessage(), "should report the missing file");
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteTopologyActionTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteTopologyActionTest.java
index e0065a0a4d71..c4faba79a201 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteTopologyActionTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/CamelRouteTopologyActionTest.java
@@ -78,7 +78,7 @@ class CamelRouteTopologyActionTest extends
ActionCommandTestSupport {
CliException e = assertThrows(CliException.class, () ->
callWithSingleProcess(command));
- assertEquals(CliExitCode.NOT_FOUND, e.getExitCode());
+ assertEquals(CliExitCode.FILE_NOT_FOUND, e.getExitCode());
assertEquals("File does not exist: doesNotExist", e.getMessage(),
"should report the missing source file");
}
@@ -94,7 +94,7 @@ class CamelRouteTopologyActionTest extends
ActionCommandTestSupport {
CliException e = assertThrows(CliException.class, command::doCall);
- assertEquals(CliExitCode.NOT_FOUND, e.getExitCode());
+ assertEquals(CliExitCode.FILE_NOT_FOUND, e.getExitCode());
assertEquals("File does not exist: route1", e.getMessage(),
"with 2+ file args, dispatch must go straight to source-file
handling and skip the "
+
"running-integration lookup entirely");
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/RouteActionJavaSourceTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/RouteActionJavaSourceTest.java
index b2dbcbdfb484..c95e88cce13e 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/RouteActionJavaSourceTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/RouteActionJavaSourceTest.java
@@ -120,7 +120,7 @@ class RouteActionJavaSourceTest {
assertThatThrownBy(() ->
command.doCallSource(List.of(missing.toString())))
.isInstanceOf(CliException.class)
.hasMessage("File does not exist: " + missing)
- .extracting(e -> ((CliException)
e).getExitCode()).isEqualTo(CliExitCode.NOT_FOUND);
+ .extracting(e -> ((CliException)
e).getExitCode()).isEqualTo(CliExitCode.FILE_NOT_FOUND);
}
@Test
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageActionTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageActionTest.java
index 419e3c961600..fa0849d08ae0 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageActionTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/action/TransformMessageActionTest.java
@@ -135,7 +135,7 @@ class TransformMessageActionTest extends
ActionCommandTestSupport {
Path template = dir.resolve("nope.txt");
assertThat(command("--body=Hello", "--language=simple",
"--template=file:" + template).doCall())
- .isEqualTo(CliExitCode.NOT_FOUND);
+ .isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).contains("Template file does not
exist: " + template);
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRunTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRunTest.java
index ec6c70f09e93..8d7041202621 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRunTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/update/UpdateRunTest.java
@@ -70,7 +70,7 @@ class UpdateRunTest extends CamelCommandBaseTestSupport {
void withoutAMavenProjectIsNotFound() throws Exception {
Files.delete(project.resolve("pom.xml"));
-
assertThat(command("4.18.0").doCall()).isEqualTo(CliExitCode.NOT_FOUND);
+
assertThat(command("4.18.0").doCall()).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).contains("No Maven project found in
the current directory");
assertThat(command).isNull();
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeRestGenerator.java
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeRestGenerator.java
index 4a82bc072596..d4a612a51b88 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeRestGenerator.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-generate/src/main/java/org/apache/camel/dsl/jbang/core/commands/generate/CodeRestGenerator.java
@@ -110,7 +110,7 @@ public class CodeRestGenerator extends CamelCommand {
File f = new File(input);
if (!f.exists() && !f.isFile()) {
printer().printErr("Input file " + input + " does not exist");
- return CliExitCode.NOT_FOUND;
+ return CliExitCode.FILE_NOT_FOUND;
}
OpenAPI doc;
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/PropertiesValidateCommand.java
b/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/PropertiesValidateCommand.java
index 0b5ae84b2e0b..1c9939ac2e6d 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/PropertiesValidateCommand.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/PropertiesValidateCommand.java
@@ -72,7 +72,7 @@ public class PropertiesValidateCommand extends CamelCommand {
}
if (reports.isEmpty()) {
- throw CliException.notFound("No properties files to validate");
+ throw CliException.fileNotFound("No properties files to validate");
}
int count = reports.values().stream().mapToInt(List::size).sum();
if (jsonOutput) {
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlValidateCommand.java
b/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlValidateCommand.java
index 94fbf7de378b..d077bb392af3 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlValidateCommand.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-validate/src/main/java/org/apache/camel/dsl/jbang/core/commands/validate/YamlValidateCommand.java
@@ -111,7 +111,7 @@ public class YamlValidateCommand extends CamelCommand {
}
if (reports.isEmpty()) {
- throw CliException.notFound("No YAML files to validate");
+ throw CliException.fileNotFound("No YAML files to validate");
}
int count = errorCounts(reports);
if (jsonOutput) {
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidateJsonTest.java
b/dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidateJsonTest.java
index 5e76c65c3ac1..588f65b187a1 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidateJsonTest.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-validate/src/test/java/org/apache/camel/dsl/jbang/core/commands/validate/ValidateJsonTest.java
@@ -103,10 +103,10 @@ class ValidateJsonTest {
Path text = dir.resolve("notes.txt");
Files.writeString(text, "not a route");
- // nothing is left to validate, which is not found (the error document
is printed by the error handler)
+ // nothing is left to validate, so file not found (the error document
is printed by the error handler)
CliException e = assertThrows(CliException.class,
() -> run(new YamlValidateCommand(main()), "--json",
text.toString()));
- assertThat(e.getExitCode()).isEqualTo(CliExitCode.NOT_FOUND);
+ assertThat(e.getExitCode()).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(printer.getStderr()).startsWith("WARN: Skipping non-YAML
file");
}
@@ -115,7 +115,7 @@ class ValidateJsonTest {
Path text = Files.writeString(dir.resolve("notes.txt"), "not a route");
CliException e = assertThrows(CliException.class, () -> run(new
YamlValidateCommand(main()), text.toString()));
- assertThat(e.getExitCode()).isEqualTo(CliExitCode.NOT_FOUND);
+ assertThat(e.getExitCode()).isEqualTo(CliExitCode.FILE_NOT_FOUND);
assertThat(e.getMessage()).isEqualTo("No YAML files to validate");
e = assertThrows(CliException.class, () -> run(new
PropertiesValidateCommand(main()), text.toString()));
assertThat(e.getMessage()).isEqualTo("No properties files to
validate");
diff --git
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
index bf7ca6b853a1..c7f49967c583 100644
---
a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
+++
b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/RunPipeline.java
@@ -83,10 +83,10 @@ public class RunPipeline {
public static final String CAMEL_INSTANCE_TYPE = "camel.jbang";
/**
- * The exit code when a file or the source directory to run does not
exist. The same value as CliExitCode.NOT_FOUND
- * of camel-jbang-core, which this module cannot depend on: keep the two
in sync.
+ * The exit code when a file or the source directory to run does not
exist. The same value as
+ * CliExitCode.FILE_NOT_FOUND of camel-jbang-core, which this module
cannot depend on: keep the two in sync.
*/
- public static final int FILE_NOT_FOUND = 3;
+ public static final int FILE_NOT_FOUND = 66;
/**
* The template for running camel-jbang in docker containers: as the first
file to run, the files are still