Skip to content

feat: add CLI --version, help command, and input validation (sprint e2e-s1.1-26544203024)#41

Open
kumaakh wants to merge 20 commits into
mainfrom
e2e-s1.1-26544203024-cli-features
Open

feat: add CLI --version, help command, and input validation (sprint e2e-s1.1-26544203024)#41
kumaakh wants to merge 20 commits into
mainfrom
e2e-s1.1-26544203024-cli-features

Conversation

@kumaakh
Copy link
Copy Markdown
Collaborator

@kumaakh kumaakh commented May 27, 2026

Summary

  • Add --version / -v flag printing fleet-e2e-toy v1.0.0 (exit 0)
  • Add help subcommand and --help / -h flags with full usage text (exit 0)
  • Add input validation for empty/blank string arguments (add subcommand, exit 1 on invalid input)
  • Add 8 CLI unit tests using spawnSync; all 29 tests pass across 3 suites

Fixes gh-1, gh-2, gh-3.

Test plan

  • npm test passes all 29 tests (CLI, validation, notes API)
  • ./tool --version prints fleet-e2e-toy v1.0.0
  • ./tool --help, ./tool -h, ./tool help all show usage text
  • ./tool add "" and ./tool add " " exit non-zero with error message
  • ./tool add "Valid Title" exits 0
  • tool wrapper uses LF endings (enforced via .gitattributes)
  • validateCliArg helper used in cli.ts (no inline duplication)

🤖 Generated with Claude Code

E2E Tester and others added 20 commits May 27, 2026 19:27
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --version flag to CLI

1 participant