Running external subcommands works okay in some cases, but not others:
- Subcommands with or without args work ok
- Passing flags to subcommands fails. Verbose output shows that _run_external_command() isn't even invoked in such cases
- However, providing the -h flag does invoke the _run_external_command(), passing --help to it, which causes a crash if the subcommand doesn't accept this flag.
- Failing to provide required args to a subcommand displays the error output of the subcommand, but also crashes due to returning a non-zero exit code
This task is about resolving the above issues (and potentially others), ensuring that external subcommands run smoothly in all scenarios, including graceful error handling. Adding some integration tests could be a good idea, too.
- The cli does not crash on external commands that exit with a non-zero exit code
- Options with and without args are correctly passed through to external subcommands
- No flags (including --help) are automatically passed through to external subcommands
- There are actual test scripts instead of the empty files in the tests/fixtures subdirs currently used for testing add_discovered_subcommands()
- There are tests that guard against reintroducing the above bugs