feat(cli): exit non-zero on invalid arguments#38
Merged
Conversation
The parser returned undefined for invalid args and cli.ts fell through to showHelp() with no exit code, so the process ended at 0. In CI that reads as a passing step even though nothing ran. createCommand now derives a parseFailed flag from yargs state. cli.ts exits 1 when the parse failed and 0 when the user invoked with no args (the intentional "show me help" path). Valid commands run as before. Added a parseFailed describe block to command-parser tests and a new cli.test.ts covering the three exit paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
aetherexited 0 on invalid input. The parser returnedundefined,cli.tsshowed help, and the process ended cleanly. A CI step running
aether app rmwith a missing arg went green while the command never executed.
This is the silent-failure case that 6A-5(d) opens with. The CLI has to be
loud about bad input before the GitHub Action wraps it, otherwise the same
bug surfaces inside pipelines where it's harder to catch.
The fix lives in two places:
command-parser.tsexports aparseFailedflag.createCommandsets itfrom yargs state: true when a
.fail()handler fired or when a recognizedcommand resolved without enough positional args, false when invoked with
no args at all.
cli.tschecksparseFailedfirst and exits 1. The no-args path stillexits 0, since that's a real request for help, not an error.
Scoped to exit codes only. The
--non-interactiveflag,--forcefordestructive ops, and CI metadata enrichment land in their own branches.
Type of change
Checklist
npm run build)Verification
337/337 tests pass. Manual smoke test on the compiled entry point:
aether nonsenseaether app rm(no args)aether(no args)aether app list(logged in)