tj / commander.js

node.js command-line interfaces made easy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

version conflict with subcommand options

answer-huang opened this issue · comments

const { program } = require('commander');

program.version('1.0.2')
program.command('split')
  .option('--version', 'display just the first substring')

program.parse();
image

how should i do to resolve this conflict

From the README:

By default program options are recognised before and after subcommands. To only look for program options before subcommands, use .enablePositionalOptions(). This lets you use an option for a different purpose in subcommands.

So you want to call program.enablePositionalOptions().

From the README:

By default program options are recognised before and after subcommands. To only look for program options before subcommands, use .enablePositionalOptions(). This lets you use an option for a different purpose in subcommands.

So you want to call program.enablePositionalOptions().

Thank you bro, sorry for my careless.