-
Notifications
You must be signed in to change notification settings - Fork 60
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
required flags prevent subcommand --help
; raise cryptic error
#101
Comments
This is actually stranger yet, and seems to have something to do with the name of the flags and not merely that they are required. I've triple-checked this because it's really so strange, so I don't think I'm crazy. import { Option, Cli, Command } from "clipanion";
async function main() {
const cli = new Cli();
cli.register(FailingCommand);
cli.register(SucceedingCommand);
try {
const command = cli.process(process.argv.slice(2));
await cli.runExit(command, {
stdin: process.stdin,
stdout: process.stdout,
stderr: process.stderr,
});
} catch (error) {
process.stdout.write(cli.error(error));
process.exitCode = 1;
}
}
class FailingCommand extends Command {
static paths = [["fail"]];
flag = Option.String("-f", {
required: true,
});
async execute() {}
}
class SucceedingCommand extends Command {
static paths = [["succeed"]];
flag = Option.String("-c", {
required: true,
});
async execute() {}
}
main(); And if I run it...
Notice that the only difference in the commands, aside from their paths, is the specific character chosen for the flag. If I change the flag in |
Might be related to this? clipanion/sources/advanced/HelpCommand.ts Lines 14 to 23 in 6f54147
I haven't really looked into how the help built-in works, but it looks like |
and if you add |
Note: This is now fixed via https://github.com/arcanis/clipanion/pull/128/files for
|
Reproduction: https://replit.com/@AndrewBradley/clipanion-repro (clicking "run" is not wired up, but the code is in "index.ts" and the shell can be used to run
node ./dist/index.js
)When a subcommand
foo
has a required option--bar
, and I try to runmycli foo --help
I get a cryptic error:I get the same error when I try to run
mycli foo
. In the former case, with--help
, I want to see help output about the command. In the latter, instead of the cryptic error, it would be ideal for the error to specifically mention that--bar
is missing, but not to suggest that thefoo
command is unrecognized.The text was updated successfully, but these errors were encountered: