You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given I am using the flag name 'port' in one command
When I define the flag name 'port' in a second command
Then the default value will be set to the one in the command highest in the alphabet.
These values are written with a function belonging to command and therefore look like they should be command-specific:
command.Flags().StringP("port", "p", "8000", "Port to expose on host")
However the function to read them does not seem to be command-specific:
cli.FlagValues().GetString("port")
There should be a way of setting the same flag for different commands without them overriding each other. There should also be a way of setting a global flag for all commands to reuse.
The text was updated successfully, but these errors were encountered:
Global flags can already be set, by virtue of a cali.Cli also being a cali.Command.
var (
// Define this here, then all other files in cmd can add subcommands to it
cli = cali.NewCli("lucli")
)
func init() {
cli.SetShort("Example CLI tool")
cli.SetLong("A nice long description of what your tool actually does")
cli.Flags().StringP("bob", "r", "default", "Which bob should we use?")
cli.BindFlags()
}
(this might already work, and be unambiguous, at least for Cobra flags, as you're only ever running one Cobra command. For Viper configs, there's still ambiguity)
Given I am using the flag name 'port' in one command
When I define the flag name 'port' in a second command
Then the default value will be set to the one in the command highest in the alphabet.
These values are written with a function belonging to
command
and therefore look like they should be command-specific:However the function to read them does not seem to be command-specific:
There should be a way of setting the same flag for different commands without them overriding each other. There should also be a way of setting a global flag for all commands to reuse.
The text was updated successfully, but these errors were encountered: