Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user to specify which script a subcommand should call #532

Closed
matthewadams opened this issue May 11, 2016 · 6 comments
Closed

Allow user to specify which script a subcommand should call #532

matthewadams opened this issue May 11, 2016 · 6 comments
Assignees

Comments

@matthewadams
Copy link

If the script a user wants to execute as a subcommand doesn't abide by the naming convention that's documented (like pm install looks for script pm-install), the user should be able to specify the script that's to be executed. For example:

// file: ./examples/pm
var program = require('..');

program
  .version('0.0.1')
  .command('install [name]', 'install one or more packages', 'myinstall') // (1)
  .command('search [query]', 'search with optional query', '../others/q.js') // (2)
  .command('list', 'list packages installed', {isDefault: true}, '/home/me/foo/bar/mylist.js') // (3)
  .parse(process.argv);

In (1), commander would assume the same directory as the current file, look for ./myinstall, then if not found, append .js, resulting in ./myinstall.js.
In (2), commander would use the path relative to the current file. No .js appended since there's already a .js extension.
in (3), commander would use the absolute path. No .js appended since there's already a .js extension.

@b4dnewz
Copy link

b4dnewz commented Aug 15, 2018

2 years... will this issue never be addressed? 😞 it is an extremely useful feature that you can use an alternative naming convention or specify a file

@abetomo
Copy link
Collaborator

abetomo commented Aug 16, 2018

Thanks for your suggestion.
I will add features.

@shadowspawn
Copy link
Collaborator

shadowspawn commented Apr 26, 2019

Pull Request #854 adds an option for this.

I am interested in feedback on executableFile as the option name?

e.g.

program
.command("example", "example description", { executableFile: "myExampleCommand" });

@shadowspawn
Copy link
Collaborator

shadowspawn commented Jul 21, 2019

Pull Request #999 is being considered for v3, adds option to override executable file name

@shadowspawn
Copy link
Collaborator

This issue will be resolved when v3.0.0 is released. Available now as a prerelease. See #1001

@shadowspawn
Copy link
Collaborator

.command now supports the executableFile option (thanks to @abetomo).
Shipped in v3: https://github.com/tj/commander.js/releases/tag/v3.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants