Skip to content

"name" option is broken as of 2.4.0 #284

@lakenen

Description

@lakenen

One of my command line flags is called '--name', but as of bfa7a73, if the name option is left off, cmd.name is a function. I suppose this is indicative of a larger problem, i.e., options are stored on top-level namespace of the command object.

e.g., say you have this file, mycmd.js

var prog = require('commander');
var command = prog
    .command('mycmd')
    .option('-n, --name [name]', 'specify a name (duh)')
    .action(function(cmd){
      console.log(cmd.name);
    });

prog.parse(process.argv);

you will see the following output:

$ node mycmd.js mycmd
[Function]

$ node mycmd.js mycmd --name Cameron
Cameron

Thoughts?

Is this wrong, or am I missing something?

Metadata

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