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

Help flag on command doesn't work with required flags #100

Closed
Embraser01 opened this issue Aug 21, 2021 · 2 comments
Closed

Help flag on command doesn't work with required flags #100

Embraser01 opened this issue Aug 21, 2021 · 2 comments

Comments

@Embraser01
Copy link

I'm using clipanion in https://github.com/Embraser01/typoas and the -h flag at the end of a command like yarn dlx @typoas/cli generator -h display:

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

  0. @typoas/cli generate <-i,--input #0> <-o,--output #0> <-n,--name #0> [--js-doc] [--only-types]
  1. @typoas/cli -h
  2. @typoas/cli -v

While running generator -h

instead of displaying the usage of the command.
I succeeded to reproduce the bug in the should display the usage per-command:

https://github.com/arcanis/clipanion/blob/master/tests/advanced.test.ts#L95-L110

By changing it to:

it(`should display the usage per-command`, async () => {
  const cli = new Cli();
  cli.register(Builtins.HelpCommand);

  class CommandA extends Command {
    static paths = [[`foo`]];

    static usage: Usage = {description: `My command A`};

    foo = Option.Boolean(`--foo`, {required:true});
    async execute() {log(this);}
  }

  cli.register(CommandA);

  expect(await runCli(cli, [`foo`, `-h`])).to.equal(cli.usage(CommandA));
  expect(await runCli(cli, [`foo`, `--help`])).to.equal(cli.usage(CommandA));
});

I found 2 issues here:

  • If I add usage here, the description will not be printed.
  • If I set the boolean flag to required, the Unknown Syntax Error is thrown
@romdej
Copy link

romdej commented Apr 26, 2024

Helllo @Embraser01, the issue seems unreproducible. Well, the error still the same with yarn dlx @typeoas/cli generator -h but it's only because there is no command matching the path generator. If I use yarn dlx @typeoas/cli generate -h I have no issue.

For the case where you were able to reproduce the issue in the mentioned test, I think it's due the missing option detailed: true in the cli.usage calls.

@Embraser01
Copy link
Author

Couldn't reproduce, I must have been tired 😅, let me close this

@Embraser01 Embraser01 closed this as not planned Won't fix, can't repro, duplicate, stale May 11, 2024
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