id: task-6 title: "CLI: Argument Parsing, Help, and Packaging" status: Done assignee: [] reporter: @MrLesk created_date: 2025-06-04 labels: ["cli", "command"] milestone: "M1 - CLI" dependencies: ["task-3"]
Description
Implement robust CLI argument parsing (e.g., using commander.js or yargs).
Provide helpful --help messages for all commands.
Use bun build --compile to create a standalone executable.
Define bin script in package.json for npm distribution.
Acceptance Criteria
- [x] All commands have clear help messages.
- [x] CLI arguments are parsed correctly.
- [x]
bun build --compileproduces a working executable. - [x]
package.jsonconfigured for CLI publishing.
Implementation Notes
CLI Framework & Argument Parsing (src/cli.ts:7-11):
- Implemented using Commander.js for robust argument parsing and command structure
- All commands provide comprehensive help messages with
--helpflag - Supports command aliases (e.g.,
taskandtasks) - Proper option parsing with short and long flags (e.g.,
-d, --description)
Help System:
- Main CLI help:
backlog --helpshows all available commands - Command-specific help:
backlog task --help,backlog doc --help, etc. - Subcommand help:
backlog task create --helpshows create-specific options - All help messages include clear descriptions and usage examples
Build System (package.json:24):
- Dual build process: Node.js distribution + standalone executable
bun build --compilecreates platform-specific binary (cli/backlog)- Node.js wrapper script (
cli/index.js) for npm distribution - Automatic executable permissions (
chmod +x) for both formats
NPM Distribution (package.json:6-8):
binfield configured to point to./cli/index.js- Enables global installation via
npm install -g backlog.md - Entry point uses ES modules with dynamic import for compatibility
Testing Coverage:
src/test/build.test.tsvalidates compiled executable functionality- Tests verify help output and binary execution
- All 111 tests pass including build verification
- CLI integration tests cover all command argument parsing
Key Features Verified:
- Complex argument parsing: multi-flag commands work correctly
- Help system: comprehensive documentation for all commands
- Executable compilation:
./cli/backlog --helpfunctions properly - NPM compatibility:
./cli/index.jsworks as distribution entry point - Cross-platform: builds succeed and tests pass on current platform
This implementation provides a professional CLI experience with both standalone and npm distribution options.