CLI Maker Command Authoring
Use this skill when the user asks to add/change CLI commands.
Files to touch
- •
src/commands/*.tsfor command definitions - •
src/cli.tsto register commands withcli.command(...) - •optionally
src/lib/*for command business logic
Command contract
Each command must include:
- •
name - •
description - •
paramsarray - •
action(args)
Example skeleton:
ts
import { Command, ParamType } from '@ideascol/cli-maker';
const myCommand: Command = {
name: 'do-something',
description: 'Does something useful',
params: [
{ name: 'target', description: 'Target name', required: true, type: ParamType.Text },
{ name: 'dry_run', description: 'Preview mode', type: ParamType.Boolean }
],
action: (args) => {
console.log(args.target, args.dry_run);
}
};
export default myCommand;
Param behavior to respect
- •Parsing formats accepted:
- •
--param=value - •
--param value
- •
- •
ParamType.Booleanexpects explicit value:--flag=trueor--flag=false. - •
ParamType.Listrequiresoptionsand value must be one of them. - •
ParamType.Custommust be JSON object or array. - •Required params missing in non-interactive mode cause exit with error.
Subcommands
- •Define subcommands inside
subcommands: Command[]. - •Help works per level:
- •
<cli> --help - •
<cli> <command> --help - •
<cli> <command> <subcommand> --help
- •
Post-edit checks
- •Build/tests pass (
npm testorbun test). - •
--helpoutput includes the new command. - •Run at least one valid invocation and one invalid invocation to validate errors.