-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Is there a way / are there plans to provide lifecycle / hooks methods? #1273
Comments
This issue or PR has been automatically marked as stale because it has not had recent activity. Please add a comment bumping this if you're still interested in it's resolution! Thanks for your help, please let us know if you need anything else. |
Closing this as it has become stale. |
@refs Yes we could implement this in v3. Are you willing to submit a PR ? |
@refs Could you provide a description of the hooks you are looking for ? |
Suggestion by user @axelrindle The concept of lifecycle hooks sounds great to me. I'd like to propose the following:
|
@axelrindle we already have Before and After Actions for Command. I definitely see the value in Before & After Flags. The After Flags becomes tricky. When should it be called ? If there is an error in flag parsing(maybe invalid flag parsing etc) should the after flag action be called. What about if there are no parse errors but one of the following happens
|
After all flags have been successfully parsed, but before the command action is executed.
I would handle this the same way the
The occurence of
Treat this as a parsing error and therefore only run hook on success. |
I just thought about |
Currently I'm providing structured config files alongside urfavecli, the problem with this is that config files for urfave are "just another way to declare flag values"; they are flat, not hyerarchical.
The workaround we're doing is ugly, as it goes against the defined priorities on urfavecli, since the only time I can set values on the flags are after these are already parsed (even the
Before
hook, flags have already been parsed by the time we reach it)I've tried implementing the flag parsing myself but the prospects of maintaining this piece aside my usual work load is dark, and I haven't dig deep enough into urfavecli codebase to submit a patch, however I am willing to invest the time.
I guess I'm asking this because I've seen in some issues and comments that there is an active development for a v3, and perhaps this has been accounted for, perhaps not, or perhaps there is still room for feature submissions.
The reference point would be kong hooks, I have not personally used Kong, but these hooks seem to do just what we want.
This is the use case I'm trying to address: https://github.com/refs/urfave-yaml
The text was updated successfully, but these errors were encountered: