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

Have a catch-all for commands that don't exist. Provide useful information on potential commands user CAN use #10

Closed
SpencerCDixon opened this issue Feb 17, 2016 · 4 comments

Comments

@SpencerCDixon
Copy link
Owner

program
  .command('*')
  .action(function(env){
    console.log('Enter a Valid command');
    terminate(true);
});

Something like this

@jamesr73
Copy link
Contributor

Seemed simple enough:

program
  .command('*')
  .action(function(cmd, env) {
    program.help()
  });

Except that this also intercepts the built-in redux help <cmd> such that the top level help is returned rather than the command specific help.

Which lead to this:

program
  .command('*')
  .action(function(cmd, env) {
    if (cmd === 'help') {
      program.emit('--help')
    } else {
      program.help();
    }
  });

Which works if you ask it nicely:

redux help generate

But barfs on missing command if you're lazy:

redux help

And barfs by running the command (?!) if you're over zealous:

redux help generate duck

Are you interested in a PR if I continue trying to refine this?

@SpencerCDixon
Copy link
Owner Author

Yeah if you get it working I'll definitely merge. Was probably going to start putting some more time into this project now that I'm settled into my new job/not ridiculously busy haha.

Appreciate you wanting to contribute!!

@jamesr73
Copy link
Contributor

Cool. I'll see if I can do any better. I used yargs on my last project and it has similar quirks ;-)

@anithri anithri added the 2.0 label Sep 18, 2017
jamesr73 added a commit to jamesr73/redux-cli that referenced this issue Sep 19, 2017
…pencerCDixon#10-cli-default

* 'master' of https://github.com/jamesr73/redux-cli:
  Starting development on 2.0
  1.9.0
  Adds yarn and updates package.json to not use explicit .bins
  Fixes redux g
  Fix example for .reduxrc
  Fix additional instances of typo in readme.md
  Fix typo in readme.md
  fix: } doesn't ( in blueprint file. guess it's a mistake :)
  Changed error message mentioned in SpencerCDixon#35
  Fixed typo in readme code example
  Releases v1.8.0 with dry run support
  added test for writeWouldCreate
  add dry run option for redux generate
  Adds changelog updates to readme
  1.7.0
  Adds -U option to 'new' command in order to generate a UI Kit boilerplate
  Fix readme typo
  Adds a flag to new command for using the redux-cli-boilerplate
  1.5.1

# Resolved Conflicts:
#	src/cli/redux-generate.js
#	src/cli/redux-new.js
anithri pushed a commit that referenced this issue Sep 30, 2017
* Add bp command with init and generate sub-commands using yargs.

* Update the default blueprint blueprint to demo the blueprint command options.

* Add option to specify command aliases to blueprint blueprint.

* Add support for 'bp new', hidden from 'bp help' for 2.0 release. 'bp help new' and 'bp new' both work.

* Add a shortcut option to blueprint blueprint. Separate function for sanitizeOptions hints that another hook would be useful.

* Load rc settings into blueprints and use for both command creation and execution.

* Allow rc file to specify blueprint aliases (overriding those in the blueprint definition)

* Specify options as a plain object that can be interrogated for prompts by the init command.

* Split yargs setup from argv parsing to support testing

* Resolve eslint error on new command

* Restore leaky sinon.stub() that was literally throwing 'random errors' in test runs.

* Update init command description to reference .blueprintrc

* Revert yargs parser to simple/default singleton now that flaky tests have been identified and fixed.

* Remove commander cli implementation.

* Rearrange cli files into better structure to support testing.

* Add src to jest roots so watch mode sees source code changes.

* Improve handling of missing or incorrect commands, address #10.

* Update blueprint blueprint to latest functionality.

* Remove old CLI commands from package.json bin.

* Add eplilogue support to blueprint commands.

* Yo-yo back to non-singleton yargs for testing.

* Add CLI parser tests, main/root command only.

* Exclude blueprint blueprint ejs template from eslint until linting can be addressed.

* Revert "Exclude blueprint blueprint ejs template from eslint until linting can be addressed."

This reverts commit dd19ea9.

* Move eslint in posttest hook (at least until blueprint linting can be addressed).

* Add tests for init sub-command.

* Lint tests, make eslint aware of jest global.

* Add tests for CLI new command.

* Lint CLI 'new' test.

* Split generate command into smaller pieces more easily tested (and mocked)

* Add tests for buildBlueprintCommand

* Remove yargs argument from buildBlueprintCommands, simplify for update when BlueprintCollection is available.

* Add tests for CLI generate.

* Lint CLI generate test. Argh.

* Update blueprint blueprint --description to accept a string for the description
@anithri
Copy link
Collaborator

anithri commented Oct 1, 2017

Addressed by #110 implemented yargs and has been merged.

@anithri anithri closed this as completed Oct 1, 2017
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

3 participants