Enhancement
Currently, the phantom CLI uses manual argument parsing in its command handlers. While functional, this approach could be improved by adopting Node.js's built-in parseArgs utility from node:util.
Benefits
- More robust parsing: Handles edge cases and complex argument combinations
- Standard CLI conventions: Automatically supports position-independent options
- Type safety: Better TypeScript support for parsed arguments
- Future-proof: Easier to add new options and maintain consistency across commands
Implementation
Replace current manual parsing approach:
export async function createHandler(args: string[]): Promise<void> {
const name = args[0];
const openShell = args.includes("--shell");
// ...
}
With parseArgs:
import { parseArgs } from 'node:util';
export async function createHandler(args: string[]): Promise<void> {
const { values, positionals } = parseArgs({
args,
options: {
shell: {
type: 'boolean',
short: 's'
}
},
strict: true,
allowPositionals: true
});
const name = positionals[0];
const openShell = values.shell;
// ...
}
Scope
This enhancement should be applied to all command handlers in the CLI layer for consistency.
Enhancement
Currently, the phantom CLI uses manual argument parsing in its command handlers. While functional, this approach could be improved by adopting Node.js's built-in
parseArgsutility fromnode:util.Benefits
Implementation
Replace current manual parsing approach:
With
parseArgs:Scope
This enhancement should be applied to all command handlers in the CLI layer for consistency.