In my , you created a nestjs cli application. It was a very basic starting point that printed a cow saying a static message in the console. previous article But what if your users demand the ability to display custom messages? That’s what you’re going to add to this article. The new and improved will display the same message by default or any string that you pass in with the argument. application --message Adding a Message Option The easiest way to add an option is to add a parser function for a parameter and add the decorator to it. @Option In the file, add the following method to your class. cow-say.command.ts CowSayCommand @Option({ flags: '--message <message>', description: 'The message we want to see the cow say', }) parseMessage(value: string) { return value; } Decorating It If you’ve used the commander library before, this should look familiar. The tells commander that if the option is provided, the user doesn’t need to provide a parameter after it. If the value were required, it would be instead. <message> --message [message] The parameter is used when the user displays help for a specific command. The description will be displayed in a column to the right of every available option. description The Parser The decorator is applied to a parser function, in this case . The function takes in a string and needs to convert it to whatever type you want at runtime. If you had a parameter, you’d need to convert a string to an integer. @Option parseMessage --count <count> Since the message should be a string, you just need to return it. Nothing fancy here. Using the Options To use the option, you need to accept two parameters in the method. The first is an array of parameters that were passed in, and the second is an options object that includes all of the parsed options. Since you aren’t using the parameters you can just ignore it. run async run(_passedParams: string[], options: { message?: string }): Promise<void> { const message = options.message ?? 'Hello World!'; console.log(cowsay.say({ text: message })); } Awesome, now if you run the program with a parameter, the cow will be saying, “Foo Bar.” --message "Foo Bar" Using Inquirer Using parsers like in the previous step works great for smaller commands. It has the advantage of being simple. But what if you would like to gracefully ask the user to enter any parameters they forgot to provide? For that, you can use the . InquirerService The first thing you need to do is define the types of inputs that will be used for each parameter. That’s done with a class decorated with and parsing methods decorated with . @QuestionSet @Question Create a file and add the following to it. cow-say.questions.ts import { Question, QuestionSet } from 'nest-commander'; @QuestionSet({ name: 'cowSay', }) export class CowSayQuestions { @Question({ type: 'input', name: 'message', message: 'What does the cow say?', }) parseMessage(value: string) { return value; } } Now, add this class as a provider to your module. ... import { CowSayQuestions } from './cow-say.questions'; @Module({ providers: [CowSayCommand, CowSayQuestions], }) export class CowSayModule {} Now the parameter needs to be updated to be mandatory in the command. message @Option({ flags: '--message [message]', description: 'The message we want to see the cow say', }) Next, inject the inquirer service into the command. constructor(private readonly inquiererService: InquirerService) { super(); } , update the method and use the inquirer service to update the options parameter. Finally run options = await this.inquiererService.ask('cowSay', options); console.log(cowsay.say({ text: options.message })); Now, when you run the command, if you don’t pass in the option the application will ask you to provide it. --message ❯ npm run start:cli > my-cli-project@0.0.1 start:cli > ts-node src/main.ts ? What does the cow say? Mooooooo __________ < Mooooooo > ---------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || Summary In this article, you expanded upon the basic created in the previous installment. You learned how to add arguments with an option parser function and used the decorator. You also learned how to use the to gracefully prompt users to enter missing parameters and integrate it into your command, enhancing user interaction. NestJS CLI application @Option InquirerService Also published . here