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.

Default subcommand with options

See original GitHub issue

Hi, I want to use a subcommand as default, and this subcommands has options. Something like this:

//app.js

program
    .command('run', 'Execute stuff', {isDefault: true})
    .command('list', 'List stuff')
    .parse(process.argv);
// app-run.js

program
    .option('-c, --config <file>', 'use a config file')
    .parse(process.argv);

This command works fine:

app run -c config.json

And this as well (executes the default subcommand):

app

but on execute the default subcommand with options:

app -c config.json

I have the followin error:

  error: unknown option `-c'

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:10

github_iconTop GitHub Comments

1reaction
shadowspawncommented, Oct 1, 2019

v4.0.0-0 prerelease published: #1067

0reactions
shadowspawncommented, Nov 1, 2019

v4.0.0 has been released which hopefully resolves this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default subcommand · Issue #975 · clap-rs/clap - GitHub
In my scenario I am not concerned about confusion with the arguments of the parent command as I only have the default help/options...
Read more >
How do I specify default subcommand? - Stack Overflow
Following doesn't work because it runs callable that doesn't have implementation. @Command( name = "tool", mixinStandardHelpOptions = true, ...
Read more >
Subcommands and the App · CLI11 Tutorial
Subcommands are keyword that invoke a new set of options and features. ... The default is CLI:::FailureMessage::simple , and you can easily define...
Read more >
Clikt - Common Options With Subcommands
This allows you to specify all options after the subcommand name. ... Options:") { val token by option(help="api token to use for requests").default("....
Read more >
Clap - Default Subcommand? : r/rust - Reddit
I've made a bit of a workaround by adding options to the main app which are then hidden, but there is no indicator...
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