davsclaus opened a new pull request, #27928: URL: https://github.com/apache/camel/pull/27928
Step 8 of [CAMEL-25388](https://issues.apache.org/jira/browse/CAMEL-25388): without an interactive terminal (a script, a CI job, an AI agent) nobody can press Enter, so no command waits for it. Today `camel get --watch`, `camel log`, `camel trace` and `camel cmd receive` run until killed, and `camel debug` busy-spins at 100% CPU. ### Watch and follow - `--watch` without `--duration` shows the output once, with `WARN: --watch needs an interactive terminal or --duration, so the output is shown once` on stderr. - New `--duration` (`DurationMixin`, millis or a duration such as `30s`) on every command that watches or follows: `camel get`/`top`/`ps`, the `cmd` actions with `--watch`, `log`, `trace`, `cmd receive` and `infra log`. It keeps going for that long and exits with `0`. One `CommandHelper.RunUntil` replaces the five copies of the "wait for Enter" thread. - `camel log`, `trace` and `cmd receive` do not follow unless `--follow` or `--duration` is given (`CamelCommand.isFollowing`). - `camel infra log` gets `--follow`: without it, it prints the end of the logs and exits. Its tailers are stopped when it is done, and a tailer is no longer started twice (`Tailer.builder().get()` already starts it). - A bare `--follow` turns following on. As a boolean option that is on by default, picocli turned it off; `arity = "0..1", fallbackValue = "true"` fixes that without taking a following name or pid as the value. - Refreshes no longer print screen escape codes when there is no terminal (they ended up in the file or pipe). - In a terminal, the end of the input (Ctrl+D) stops a watch or follow, like Enter. ### Interactive-only commands `camel debug`, `nano`, `shell`, `edit`, `tui`, `ask` without a question, `run --prompt` and `get history --it` exit with `2` and `ERROR: <command> requires an interactive terminal` (`CamelCommand.requireInteractiveTerminal`). `camel tui --record` (plays a tape headless) and the browser sessions of `camel tui --web` still run. `camel debug --remote-attach` uses `ProcessFinder.requireOne` to find the integration. ### Other - `camel hawtio` opens no browser without a terminal and prints the URL; `--openUrl` is now `--open-url` (the old name still works). - `EnvironmentHelper.hasTerminal()` uses `Console.isTerminal()` on Java 22 and later, where there is a console also when the input is redirected (moved from `camel ask`). ### Docs - 4.24 upgrade guide: "no command waits for a terminal that is not there". - `camel-jbang-exit-codes.adoc`: "Without a terminal". - The generated command pages list `--duration`, and `DurationMixin` lives in the `commands` package, where the doc generator finds mixins. ### Tests - `NoTerminalTest` (through `CamelJBangMain`, the way `camel` runs): each interactive-only command exits 2 with its message, `--watch` runs once with the warning, `--watch --duration` and `log --duration` stop after the duration, `log` does not follow, `ReadConsoleTask` stops at the end of the input, `RunUntil`. - `InfraLogTest`: the end of the log without a terminal (`--lines`), following for a `--duration`. - `HawtioTest`: no browser without a terminal, `--open-url`, `--open-url=false`, `--openUrl=true`. - `ActionCommandsTest`: a bare `--follow` is true and does not take the name. - Real processes without a terminal (stdin from `/dev/null`): every interactive-only command exits 2 within a second, `ps --watch` once, `ps --watch --duration=3s` two refreshes in 3s, `log` returns, `log --duration=2s` returns after 2s. - `mvn test` of camel-jbang-core and camel-jbang-plugin-tui: all tests pass; camel-jbang-plugin-edit builds. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
