I am using yargs for getting CLI arguments. I want to know the difference between command and option.
const argv = yargs
.command(
'add',
'Add a new note',
{
title: titleOptions,
body: bodyOptions
})
.argv;
And
const argv = yargs
.option('address', {
alias: 'a',
demand: true,
describe: 'Address for fetching weather'
})
.help()
.alias('help', 'h')
.argv
One difference is semantics: commands perform actions, options alter the way the actions are to be performed. Another important difference is that options can be assigned values. For example:
git commit --message "Initial commit"
In the example above, commit
is the command, and message
is the option. The message
option has a value of "Initial commit". You can also have options without values, which are referred to as "flags".
git fetch --no-tags
Here we're using the no-tags
flag to tell Git to fetch everything from the upstream branch but exclude tags.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With