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 subcommands to handle --help #62

Closed
arichardsmith opened this issue May 12, 2017 · 1 comment
Closed

Allow subcommands to handle --help #62

arichardsmith opened this issue May 12, 2017 · 1 comment

Comments

@arichardsmith
Copy link

arichardsmith commented May 12, 2017

Currently when handling subcommands using separate meow instances like this:

const bar = argv => {
	const cli = meow({
		argv,
		help: `
		  Usage
		    $ foo bar <input>
	`});
};

const cli = meow(`
	Usage
	  $ foo <command>

	Commands
	  bar
`);

// Check cli.input and handle commands

If the user enters $ foo bar --help they get the help for foo and not foo bar

There's a wrapper called moggie that handles subcommands, but I was thinking we could to add a commands: [commands] option to meow so it doesn't block the --help flag?

Meow could either:

  • Not show help if a command is matched, leaving everything else to the user to handle
  • Handle the argv filtering and return the matched command and filtered argv

I'm happy to write something and submit a PR.

@angeloashmore
Copy link
Contributor

angeloashmore commented Sep 2, 2017

Running into this issue now. A subcommand implements it's own meow instance with it's own help text. Not using moggie.

Rather than providing a list of commands to meow, since that is a moggie-specific solution, maybe provide a toggle to turn off the automatic --help handler? The programmer could then handle how and when showHelp() is called.

I could submit a PR if necessary. Unless there is a better way to handle this with the existing options in meow or minimist?

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

2 participants