feat: add CLI --version, help command, and input validation (sprint e2e-s1.1-26544203024)#41
Open
kumaakh wants to merge 20 commits into
Open
feat: add CLI --version, help command, and input validation (sprint e2e-s1.1-26544203024)#41kumaakh wants to merge 20 commits into
kumaakh wants to merge 20 commits into
Conversation
…203024) Plan covers three issues: --version flag, input validation for empty/blank strings, and help command. All share the CLI entry point in one cohesive phase. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Plan passes all 13 checklist items. Single cohesive phase with clear done criteria, correct task ordering, thorough risk register, and full alignment with sprint requirements. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add src/cli.ts with argument parsing skeleton - Add tool (Unix shell wrapper for ts-node) - Add tool.cmd (Windows batch wrapper for ts-node) - Enforce LF line endings via existing .gitattributes
- Read version from package.json at runtime - Print 'fleet-e2e-toy vX.X.X' to stdout - Exit with code 0 after printing version - Handle both --version and -v (short form)
- Add help subcommand handler - Add --help and -h flag handlers - Print usage text listing all commands (help, add) and flags - Exit with code 0 for all help variants
- Add validateCliArg function to src/utils/validation.ts - Add 'add <title>' subcommand to src/cli.ts - Validate title argument and reject empty/whitespace-only strings - Print user-friendly error message to stderr on validation failure - Exit with code 1 on validation failure, 0 on success
- Create tests/cli.test.ts with end-to-end tests using spawnSync - Test --version and -v flags output correct version and exit 0 - Test help, --help, -h flags output usage text and exit 0 - Test add command validation: empty string, whitespace-only strings fail - Test add command with valid title succeeds - Platform-conditional invocation for Unix vs Windows
- Simplify test runner to invoke npx ts-node directly on src/cli.ts - This approach works cross-platform without shell wrapping - Avoids path/shell compatibility issues
- Replace require() calls with ES6 imports - Use proper TypeScript for better compatibility with ts-node - Fixes issue where __dirname wasn't resolving correctly
- Use 'node -r ts-node/register' for proper TypeScript execution - This approach works correctly with ts-node and captures output properly - Remove debug logging
Two issues found: 1. CRLF line endings on `tool` script (.gitattributes only covers *.sh) 2. validateCliArg defined but not called — cli.ts uses inline validation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added 'tool text eol=lf' to .gitattributes - Re-normalized tool script to LF line endings - Prevents CRLF corruption on Windows that would break Linux CI
- Import validateCliArg from ./utils/validation - Replace inline empty/whitespace check with validateCliArg() call - Error message now comes from the shared helper for consistency
Both prior findings resolved: CRLF on tool script fixed via .gitattributes re-normalization, validateCliArg now imported and used in cli.ts. All 29 tests pass, lint/build clean, no regressions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
--version/-vflag printingfleet-e2e-toy v1.0.0(exit 0)helpsubcommand and--help/-hflags with full usage text (exit 0)addsubcommand, exit 1 on invalid input)spawnSync; all 29 tests pass across 3 suitesFixes gh-1, gh-2, gh-3.
Test plan
npm testpasses all 29 tests (CLI, validation, notes API)./tool --versionprintsfleet-e2e-toy v1.0.0./tool --help,./tool -h,./tool helpall show usage text./tool add ""and./tool add " "exit non-zero with error message./tool add "Valid Title"exits 0toolwrapper uses LF endings (enforced via.gitattributes)validateCliArghelper used incli.ts(no inline duplication)🤖 Generated with Claude Code