import { Command, CommandRunner, Option } from 'nest-commander'; @Command({ name: 'sayHello', options: { isDefault: true } }) export class SayHelloCommand implements CommandRunner { async run(inputs: string[], options: { name: string; age: number }): Promise<void> { console.log('options', options); console.log('inputs', inputs); if (options.age < 13) { console.log(`Hello ${options.name}, you're still rather young!`); } else if (12 < options.age && options.age < 50) { console.log(`Hello ${options.name}, you're in the prime of your life!`); } else { console.log(`Hello ${options.name}, getting up there in age, huh? Well, you're only as young as you feel!`); } } @Option({ flags: '-n --name <personName>' }) parseName(val: string) { return val; } @Option({ flags: '-a --age <age>' }) parseAge(val: string) { return Number.parseInt(val, 10); } }