Skip to content

Default subcommand with options #461

@oscarotero

Description

@oscarotero

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'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions