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

Triage: Git-style subcommands #944

Closed
shadowspawn opened this issue Mar 30, 2019 · 9 comments
Closed

Triage: Git-style subcommands #944

shadowspawn opened this issue Mar 30, 2019 · 9 comments

Comments

@shadowspawn
Copy link
Collaborator

shadowspawn commented Mar 30, 2019

Executable lookup

The file layout and lookup for doing subcommands is not customisable.

Issues:

Pull Requests:

Lookup varies by filename/package/platform

Issues:

Sub subcommands

When subcommands are scaled up to doing sub subcommands, people want easier approaches or nicer layout.

Pull Requests:

Allow other executables

Pull Requests:

Help

Pull Requests:

Early history

And where it all began...

@emilyrohrbough
Copy link

@shadowspawn I recently discovered the ability to define subcommand using commandar. Its great! I have run into a few different issues - the initial ones being that I use a Mac and our project configuration results in the incorrect file resolution for sub-commends. (See below for project context). I've been able to play around a bit to propose a possible fix to the issue you've called out on #604 (comment)

(I think the next direction we want to explore with git-style commands is more control over how the commands are found. Source file naming and directory layout is one form of that, but search paths where the commands are looked for is another as in this Pull Request. i.e. installed node_modules, search path for commands like npm uses, etc.)

It seems like explicating allowing the consumer to define the root directory path would resolve this issue:

commander
  .rootDir(__dirname) // fallback to bin exec path if undefined
  .command('compile', 'compile source code')

OR

commander
  .command('compile', 'compile source code', { scriptPath: path.resolve(__dirname, 'my-script-compile') })
Project Context
/.bin
    /run-script.js // references ../scripts/run-script/run-script.js
/scripts
    /other-scripts // non-released scripts relative to my project
    /run-script
         /run-script.js
         /run-script-compile.js
         /run-script-test.js
package.json
// package.json
"bin": { "run-script": "./bin/run-script" },
>> node ./bin/run-script compile
error: run-script-compile(1) does not exist, try --help

>> node scripts/my-script/run-script.js compile
**successful**

@shadowspawn

This comment has been minimized.

@emilyrohrbough

This comment has been minimized.

@holmrenser
Copy link

You should probably add #828 to this.

@shadowspawn
Copy link
Collaborator Author

@holmrenser Not quite what I had in mind originally, but done. Thanks. 🙂

@shadowspawn
Copy link
Collaborator Author

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

@Piccirello
Copy link

Is this issue fixed now that v3 has been released?

@shadowspawn
Copy link
Collaborator Author

shadowspawn commented Aug 19, 2019

Around half of the referenced issues are now closed, and executableFileallows a work-around for some of the open issues, but there are still multiple open issues. In particular, I want to investigate the lookup differences across platforms.

tonywoode added a commit to tonywoode/quickPlayNode that referenced this issue Oct 9, 2019
...tj/commander.js#944
due to isues with the sub-sub command imp of commander (some people say 'nested'
subcommands), in particular windows filename lookup issues with the
git-style imp,  I'm very untempted to fix my earlier error of treating subcommands as
flags, but I CAN easily namespace
@shadowspawn
Copy link
Collaborator Author

This triage issue has been inactive for a while, and no longer feels to me like a call to action. The improvements to the README to make action/executable conventions clearer, the addition of executableFile, and ongoing work on nested subcommands for action handlers address the major themes.

Closing as suggested by @Piccirello !

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

No branches or pull requests

4 participants