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

Wrong help behavior for commands with proxy options #88

Open
lordofthelake opened this issue May 15, 2021 · 0 comments
Open

Wrong help behavior for commands with proxy options #88

lordofthelake opened this issue May 15, 2021 · 0 comments

Comments

@lordofthelake
Copy link
Contributor

lordofthelake commented May 15, 2021

This is a toy implementation of a command that is supposed to execute a sub-command for each package in a monorepo. It takes as arguments the sub-command to run in the context of each package, and an optional flag to exclude certain packages from the process.

export class WorkspaceEachCommand extends Command<BaseContext> {
  static paths = [["each"]];

  exclusions = Option.Array("-x,--exclude");
  subcommand = Option.Proxy();

  async execute(): Promise<number | void> {
    const { stdout } = this.context;
    const { exclusions, subcommand } = this;
    stdout.write(JSON.stringify({ exclusions, subcommand }));
  }

The usage (after taking into account #85, having the flags preceding the command) would be:

$ mytool -x ugly-package -x other-package-i-dont-like each do-something-interesting
{"exclusions":["ugly-package","other-package-i-dont-like"],"subcommand":["do-something-interesting"]}

This works correctly, or at least according to the expectations lined out in #85. If I try to get help for this command, though, things go wrong:

$ mytool each --help
{"subcommand":["--help"]}

Inverting the command and the flag also goes wrong – for different reasons:

$ mytool --help each
Unknown Syntax Error: Extraneous positional argument ("each").

$ mytool -h

If I type a wrong command, the help text suggests the wrong syntax, with the flags after the command. Given how the usage function is structured, I think it would show up also in the help for the single command, if it could be accessed.

$ mytool wrong 
Unknown Syntax Error: Command not found; did you mean one of:

  0. mytool -h
  1. mytool -v
  2. mytool each [-x,--exclude #0] ...

While running wrong

Any suggestions for that?

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

1 participant