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.

Add ability to specify a default subcommand

See original GitHub issue

Just like now running now deploy by default, we could add the ability to specify a default subcommand. Maybe like this: .defaultCommand('deploy', 'Deploy') or .command('deploy', 'Deploy', { defaultCommand: true } or via the options in .parse(process.argv, { defaultCommand: 'deploy' }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ntwcklngcommented, Apr 16, 2017

@jcurtis args.sub returns an array of all subcommands from process.argv. e.g.

const args = require('args');

args.command('import', 'Import Command')

console.log(args.sub)

args.parse(process.argv)

if (!args.sub[0]) args.showHelp() // calling the script without a subcommand will show help
$ node script.js
[]
$ node script.js import
['import']

Does that help?

1reaction
leocommented, Apr 16, 2017

The default command should be the code contained within the main binary. If you need an alias for that, simply define a new command and make it load the main binary.

You can define it in the init function here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Default sub-command · Issue #41 · alecthomas/kong - GitHub
I'm aiming to have a command with subcommands where there is a default subcommand when no subcommand is entered on the command line....
Read more >
Defining Commands and Subcommands | Documentation
Start by defining the root Math command. You can provide a static configuration property for a command that specifies its subcommands and a...
Read more >
clap::AppSettings - Rust - Docs.rs
Displays the arguments and SubCommand s in the help message in the order that they were declared in, and not alphabetically which is...
Read more >
Sub-parsers - Real Python
A sub-parser gives you the ability to write commands within your script. ... I'll be using this default argument to invoke my subcommand...
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