urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
21.9k stars 1.69k forks source link

Execute `runFlagActions` before `c.Before` #1844

Closed axelrindle closed 6 months ago

axelrindle commented 6 months ago

I have a flag named config which specifies the path to an alternative config file to use. I do the config loading in the c.Before hook.

However I noticed that the flag actions are run after the c.Before hook.

https://github.com/urfave/cli/blob/d391482425267827a306b820f55d236ad9b3c78d/command.go#L216-L227

How can I achieve the flag action being run before the c.Before hook?

dearchap commented 6 months ago

@axelrindle As of now it is not possible. There has been some discussion on lifecycle hooks for v3. See #1273 . If you have suggestions of how you'd like to improve this behavior it would be great.

axelrindle commented 6 months ago

The concept of lifecycle hooks sounds great to me. I'd like to propose the following:

dearchap commented 6 months ago

@axelrindle I'm going to move this conversation to #1273 and close this issue