Refactor flags
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

Signed-off-by: Jan Tytgat <jan.tytgat@corelayer.eu>
This commit is contained in:
Jan Tytgat
2025-06-09 22:36:45 +02:00
parent ee7cb7e422
commit b37a283dfb
2 changed files with 11 additions and 7 deletions

View File

@ -50,7 +50,7 @@ func persistentPreRunFuncE(cmd *cobra.Command, args []string) error {
slogd.FromContext(cmd.Context()).Log(cmd.Context(), slogd.LevelTrace, "executing PersistentPreRun")
// Make sure we can always get the version
if versionFlag.Value || cmd.CommandPath() == strings.Join([]string{appName, versionName}, " ") {
if versionFlag.Value || cmd.CommandPath() == strings.Join([]string{appName, versionFlagName}, " ") {
slogd.FromContext(cmd.Context()).LogAttrs(cmd.Context(), slogd.LevelTrace, "overriding command", slog.String("old_function", runtime.FuncForPC(reflect.ValueOf(cmd.RunE).Pointer()).Name()), slog.String("new_function", runtime.FuncForPC(reflect.ValueOf(versionRunFuncE).Pointer()).Name()))
cmd.RunE = versionRunFuncE
return nil