You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 the hook 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 cliffy parse command.
The text was updated successfully, but these errors were encountered:
andrewthauer
changed the title
feature request: ability to parse arguments without execution
Feature: Ability to parse arguments without execution
Jul 19, 2023
Yes, i already had this in mind.
My plan was to expose the execute method and add an execute option to the parse method to skip the command execution and only return the parse result. Something like this:
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: