lib.App: Fix --help with required top-level args #65
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/feature/20260817-lib-app-fix-help-with-required-top-level-args"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
lib.App: Fix --help with required top-level args
_build_parser() does an early parse_known_args() to configure logging from the command line, but that call also enforces the top-level required arguments. --help is registered only after the early parse so the subcommands are present in the rendered help, so an app with a required top-level positional, such as a root Cmd that takes a config-file, exits with "required: config-file" on --help before the final parse_args() in __run() can handle it.
Skip the early parse when help or shell completion is requested (the add_all_parsers flag, already set for -h, --help, and argcomplete). The subcommands and --help are still registered, and the final parse_args() shows the help without enforcing the required arguments. The log-flag configuration and the running-command debug line move inside the guard; neither help nor completion logs, so they do not need them.