I am using yargs to add command line options for the arguments passed to the script. When i issue the help command along with the script name, It does not display the help for add parameter.
const yargs=require('yargs');
 const argv= yargs.command('add', 'ADD A NOTE TO A FILE', {
    title : {
        describe : 'title of the file',
        demand: 'true'
    }
})
.help()
.argv;
root# node mainFile_node.js --help
Options:
  --help     Show help                                                 [boolean]
  --version  Show version number
     node mainFile_node.js add
YARGS ARGV:-{ _: [ 'add' ], '$0': 'mainFile_node.js' }
                const yargs = require("yargs");
yargs.command({
  command: "add",
  describe: "Add new note",
  builder: {
    title: {
      // describe: 'note title',
      demandOption: true,
      type: "string"
    }
  },
  handler: function(argv) {
    console.log("My title: " + argv.title);
  }
});
yargs.parse();
Then run in the command line:
node filename.js add --title="title name"
                        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