On the next line, I'll call .command again, passing in the command name. Let's do the list command first because this one is really easy, no arguments are required. Then we'll pass in the description for the list command, List all notes, as shown here:
.command('list', 'List all notes')
.help()
.argv;
Next up, we'll call command again. This time we'll do the command for read. The read command reads an individual note, so for the description for the read command, we'll use something like Read a note:
.command('list', 'List all notes')
.command('read', 'Read a note')
.help()
.argv;
Now the read command does require the title argument. That means we are going to need to provide that options object. I'll take title from add command, copy it, and paste it in the read command options object:
.command('list', 'List all notes')
.command('read', 'Read a note', {
title: {
describe: 'Title of note',
demand: true,
alias: 't'
}
})
.help()
.argv;
As you probably just noticed, we have repeated code. The title configuration just got copied and pasted into multiple places. It would be pretty nice if this was DRY, if it was in one variable we could reference in both locations, in add and read commands.
Will call command for remove, just following where we called the command for read. Now, the remove command will have a description. We'll stick with something simple like Remove a note, and we will be providing an options object:
.command('remove', 'Remove a note', {
})
Now I can add the options object identical to the read command. However, in that options object, I'll set title equal to titleOptions, as shown here, to avoid the repetition of code:
.command('remove', 'Remove a note', {
title: titleOptions
})