I am working on a CLI Project, where the user has to login before using any of its other commands. Below are the commands that the user will interact with.
- oms login -u username -p -a auth_url
- oms get -u url
When I'm trying to see the help for oms login , it is showing help for the oms get command.
const argv = require('yargs/yargs')(process.argv.slice(2))
.usage('Usage: $0 <command> [options]')
.command({
command: "oms login",
desc: "Login the User to OMS",
builder: {
username: {
alias: 'u',
demandOption: true
},
password: {
alias: 'p',
demandOption: true
},
auth_url: {
alias: 'a',
demandOption: true
}
},
handler: (argv) => console.log(argv),
})
.command({
command: "oms get",
desc: "Get the Status",
builder: {
url: {
alias: 'u',
demandOption: true
}
},
handler: (argv) => console.log(argv),
})
.help('h')
.alias('h', 'help')
.wrap(null)
.argv;
Help from oms login
PS F:\node\REST-CLI\cli> node .\index.js oms login --help
index.js oms get
Get the Status
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
-u, --url [required]
Help from oms get
PS F:\node\REST-CLI\cli> node .\index.js oms get --help
index.js oms get
Get the Status
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
-u, --url [required]
I'm using above code, Kindly let me know me where I'm doing the mistake. Thanks