-
-
Notifications
You must be signed in to change notification settings - Fork 70
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
Feature: Ability to parse arguments without execution #647
Comments
@c4spar - Curious if you have any thoughts on this? |
Sry for late reply! Yes, i already had this in mind. const { options, args, cmd } = await cmd.parse(Deno.args, { execute: false });
if (cmd !== zshHookCommand) {
await doctor();
}
await cmd.execute(options, args); |
👍 Yes, this seems like a reasonable approach that is backwards compatible as well. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it would be useful if it were possible to parse the command line arguments without also executing the command actions. This would allow you add some logic in between parsing and execution.
A simple use case would be that you want to run a periodic check on startup, but only run for certain commands. For example you run a
doctor
command every day, but say you have a shell hook command (e.g.eval "$(my-cli hook zsh)"
) which you always want to be fast and never run the doctor checking logic when thehook
command is run. The same could be said for auto update checking, etc.NOTE: I've been able to hack this by adding custom parsing logic before calling
rootCommand.parse
. However, this is not ideal as my custom parsing logic doesn't have all the same logic as the cliffyparse
command.The text was updated successfully, but these errors were encountered: