ConstDefine flag that accepts a string value
Optionaloptions: Partial<Omit<StringFlag<Type>, "type">>Configuration options for the string flag
export class MakeCommand extends BaseCommand {
@flags.string({ description: 'Database connection name', alias: 'c' })
declare connection?: string
@flags.string({ description: 'Template name', required: true, default: 'default' })
declare template: string
}
// Usage: node ace make --connection=mysql --template=api
// Usage: node ace make -c mysql --template=api
Define flag that accepts a boolean value
Boolean flags don't require a value - their presence indicates true. They can optionally support negated variants with --no-flag-name.
Optionaloptions: Partial<Omit<BooleanFlag<Type>, "type">>Configuration options for the boolean flag
export class MigrateCommand extends BaseCommand {
@flags.boolean({ description: 'Skip confirmation prompts', alias: 'f' })
declare force: boolean
@flags.boolean({ description: 'Run in dry mode', showNegatedVariantInHelp: true })
declare dryRun: boolean
}
// Usage: node ace migrate --force
// Usage: node ace migrate -f
// Usage: node ace migrate --dry-run or --no-dry-run
Define flag that accepts a numeric value
Optionaloptions: Partial<Omit<NumberFlag<Type>, "type">>Configuration options for the number flag
export class ServeCommand extends BaseCommand {
@flags.number({ description: 'Port number', alias: 'p', default: 3000 })
declare port: number
@flags.number({ description: 'Number of workers', required: false })
declare workers?: number
}
// Usage: node ace serve --port=8080
// Usage: node ace serve -p 8080 --workers=4
Define flag that accepts an array of values
Array flags can be specified multiple times to build up an array of values.
export class BuildCommand extends BaseCommand {
@flags.array({ description: 'Include additional files' })
declare include?: string[]
@flags.array({ description: 'Environment variables', alias: 'e' })
declare env?: string[]
}
// Usage: node ace build --include=*.js --include=*.css
// Usage: node ace build -e NODE_ENV=production -e DEBUG=false
// Results: include = ['*.js', '*.css'], env = ['NODE_ENV=production', 'DEBUG=false']
export class MakeCommand extends BaseCommand {
@flags.boolean({ description: 'Skip confirmation prompts' })
declare force: boolean
@flags.string({ description: 'Database connection', alias: 'c' })
declare connection?: string
@flags.array({ description: 'Additional tags' })
declare tags?: string[]
}
Namespace for defining flags using decorators.
Flags are named options that commands can accept from the CLI. They can be passed using --flag-name or -alias syntax and are made available as properties on the command instance.