Repository navigation
fix(cli): print the version for --version and -v - #354
Conversation
|
@claude /review |
|
Claude finished @theCodeDrift's task in 8m 10s —— View job Review completeReview mode: incremental — read 0 prior review thread(s) before reviewing.
AssessmentSolid, well-scoped fix. The core mechanism — intercepting Posted 2 inline comments, both low-severity / plausible edge cases, not blocking:
No correctness bugs found in the interception logic, the |
Read in full. The — AI Coding Agent |
The entry runs the root command through citty's runCommand rather than runMain so the finally that emits cli_run still runs, and --help was re-implemented in front of dispatch for that reason. --version was not, so it reached the root command as an unknown flag and rendered the usage banner; -v was never an alias at all. hasVersionFlag scans argv the way hasHelpFlag does, so a directory or a path after -- that reads like -v is still a value, and the flag answers from any position: taskless check --version prints the version instead of silently dropping the flag and running check. The root args list -v, --version so --help documents it.
…Flag Both did the same splitRawArguments walk over different literals; a private hasFlag carries the scan once and each keeps its own name.
6b5239a to
a7c786f
Compare
What
taskless --versionandtaskless -vprint the version followed by a newline on stdout and exit 0. Both flags are listed underOPTIONSin the root--help. The flag answers from any position, sotaskless check --versionprints the version as well, mirroring how--helpis resolved.Why
packages/cli/src/index.tsruns the root command through citty'srunCommandrather thanrunMain, on purpose, so thefinallythat emits thecli_runtelemetry denominator still runs;--helpwas re-implemented in front of dispatch for that reason, but--version(the other flagrunMainimplements frommeta.version) was not, so it reached the root command as an unknown flag and rendered the usage banner.-vwas never a citty alias at all.hasVersionFlaguses the samesplitRawArgumentsscan ashasHelpFlag, sotaskless -d -v checkstill names a directory andtaskless check -- -vstill names a path. Position is deliberately not consulted: the question is about the tool, not the subcommand, no subcommand defines-vor--version, and before this changecheck --versionsilently dropped the flag and ran a full check. The version path returns normally into the samefinally, socli_runis still counted; a test pins that alongside the existing help guard.How verified
Measured on a fresh
pnpm buildofmain(0.11.2) before the change:After:
pnpm build,pnpm typecheck,pnpm lint, andpnpm --filter @taskless/cli test(95 files, 1541 tests) all pass. New tests live inpackages/cli/test/version-flag.test.ts: exact<version>\nstdout for both flags with empty stderr, the subcommand-position case, the--escape, the--helplisting, thehasVersionFlagtable, and thecli_runemission guard.Fixes #352