cli icon indicating copy to clipboard operation
cli copied to clipboard

Values from a function return

Open abdennour opened this issue 4 years ago • 0 comments

Checklist

  • [x] Are you running the latest v2 release? The list of releases is here.
  • [x] Did you check the manual for your release? The v2 manual is here
  • [x] Did you perform a search about this feature? Here's the Github guide about searching.

What problem does this solve?

Sometimes, Global flag ( used by all subocommands) requires dynamic initialization. Thus, literal default values, values from env vars, values from file content or even values from alt src will not work. If this dynamic initialization does not done in a one place, it will lead to repeating ourselves then not complying with DRY.

Solution description

  		Name:    "myflag",
		Value:   "hello",
                ValueFromFunc: () string {
                       // read value set by user ( if any)
                     //.. do something
                    // return a-string
                }

Describe alternatives you've considered

For now, i am just repeating myself everywhere

abdennour avatar Jan 17 '22 04:01 abdennour