Skip to content

Flag Action should be called when value is set by alternative sources.  #2041

@project0

Description

@project0

Checklist

  • Are you running the latest v3 release? The list of releases is here.
    v3.0.0-beta1
  • Did you check the manual for your release? The v3 manual is here.
  • Did you perform a search about this feature? Here's the GitHub guide about searching.

What problem does this solve?

Fix action beeing called for all circumstances when a value is set by either a flag or alternative source. Currently the flag action is only executed when given as argument.

example:

		Flags: []cli.Flag{
			&cli.StringFlag{
				Name:    flag_log_level,
				Usage:   "The log level (trace, debug, info, warn, error, fatal, panic)",
				Value:   "info",
				Sources: cli.EnvVars(flagEnv(flag_log_level)),
				Action: func(ctx context.Context, cmd *cli.Command, value string) error {
					log.Info("Setting log level to ", value)
					level, err := log.ParseLevel(value)
					if err != nil {
						return err
					}
					log.SetLevel(level)
					return nil
				},
			},

Solution description

When a env var is set, the action should be called.

Describe alternatives you've considered

not using in this case as it is has no consistent experience for users.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/v3relates to / is being considered for v3kind/bugdescribes or fixes a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions