Skip to content

Can not use action as option name #1020

Closed
@dehghani-mehdi

Description

Hi,

Consider following code:

program
    .command('command <name>')
    .option("-a, --action", "Action")
    .description('Demo')
    .action((name, options) => {
        console.log(`name: ${name}`);
        console.log(`action: ${options.action}`);
    });

When I call it like this: command NAME -a, the output will be:

name: NAME
action: undefined

But when I call it like this: command NAME -a -a, the output will be:

name: NAME
action: true

Now if I change .option("-a, --action", "Action") to .option("-a, --action_", "Action") and console.log(action: ${options.action}); to console.log(action: ${options.action_}); and call it like this command NAME -a, the output will be:

name: NAME
action: true

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions