question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

subcommands can't have a --version option

See original GitHub issue

A primary command can take a --version option with the following code:

args.option('version', 'The version of the thing');

const flags = args.parse(process.argv, {
  version: false,
});

When I run my-command my-subcommand --help, I see

 -v, --version        The version of the thing

But when I run my-command my-subcommand --version=foo, flags.version is unpopulated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
jamesarosencommented, Aug 29, 2017

I missed

If a function was passed through at this parameter, args will call it instead of running the binary related to that command. The function receives three arguments:

in the readme. Nice!

1reaction
ntwcklngcommented, Aug 29, 2017

@jamesarosen this is also possible with args. You can put your code in the init function like this:

args.command('foo','foo subcommand', () => { 
// your code 
})

Then, the initfunction gets executed instead of running the binary for the subcommand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get options from sub command exes #563 - GitHub
In my 'foo' sub command file (Eg. pm-foo.js) how do I get hold of the options passed? pm.js: ... program .version('0.0.1') .command('foo ...
Read more >
python - argparse solution requested for commands and ...
If a command is used, some sub-commands or options are required. I have a hard time getting this done using the argparse library....
Read more >
Commands and Groups — Click Documentation (8.1.x)
Suppose we have a program called tool.py , containing a subcommand called sub . tool.py --help will return the help for the whole...
Read more >
svn—Subversion Command-Line Client - SVN Book
While Subversion has different options for its subcommands, all options exist in a single namespace—that is, each option is guaranteed to mean the...
Read more >
file — CMake 3.25.1 Documentation
If the ENCODING option is not provided and the file has a Byte Order Mark, the ENCODING option will be defaulted to respect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found