@@ -63,16 +63,16 @@ var rootCmd = &cobra.Command{
63
63
}
64
64
}
65
65
66
- color , _ := cmd .Flags (). GetString ( "color" )
67
- switch color {
68
- case "auto" :
66
+ color := cmd .Flag ( "color" ). Value .( * ColorMode )
67
+ switch * color {
68
+ case ColorAuto :
69
69
cli .DoColor = cli .CanColor
70
- case "always" :
70
+ case ColorAlways :
71
71
cli .DoColor = true
72
- case "never" :
72
+ case ColorNone :
73
73
cli .DoColor = false
74
74
default :
75
- return fmt . Errorf ("invalid color option: %s" , color )
75
+ panic ("invalid color mode" )
76
76
}
77
77
78
78
if _ , _ , err := net .SplitHostPort (server ); err != nil {
@@ -575,7 +575,8 @@ var logoutCmd = &cobra.Command{
575
575
}
576
576
577
577
func main () {
578
- rootCmd .PersistentFlags ().String ("color" , "auto" , `Colorize output; "auto", "always" or "never"` )
578
+ colorMode := ColorAuto
579
+ rootCmd .PersistentFlags ().Var (& colorMode , "color" , `Colorize output; "auto", "always" or "never"` )
579
580
rootCmd .PersistentFlags ().StringVarP (& server , "cluster" , "s" , defFabric , "Cluster to connect to" )
580
581
rootCmd .PersistentFlags ().BoolVarP (& cli .DoVerbose , "verbose" , "v" , false , "Verbose logging" )
581
582
rootCmd .PersistentFlags ().BoolVar (& cli .DoDryRun , "dry-run" , false , "Dry run (don't actually change anything)" )
@@ -623,7 +624,7 @@ func main() {
623
624
rootCmd .AddCommand (secretsCmd )
624
625
625
626
// Compose Command
626
- composeCmd .PersistentFlags ().StringP ("file" , "f" , "docker- compose.yml " , " Compose file path" )
627
+ composeCmd .PersistentFlags ().StringP ("file" , "f" , "* compose.y*ml " , ` Compose file path` )
627
628
composeCmd .MarkPersistentFlagFilename ("file" , "yml" , "yaml" )
628
629
// composeCmd.Flags().Bool("compatibility", false, "Run compose in backward compatibility mode"); TODO: Implement compose option
629
630
// composeCmd.Flags().String("env-file", "", "Specify an alternate environment file."); TODO: Implement compose option
@@ -684,7 +685,7 @@ func main() {
684
685
var derr * cli.ComposeError
685
686
if errors .As (err , & derr ) {
686
687
compose := "compose"
687
- composeFile := composeCmd .PersistentFlags (). Lookup ("file" )
688
+ composeFile := composeCmd .Flag ("file" )
688
689
if composeFile .Changed {
689
690
compose += " -f " + composeFile .Value .String ()
690
691
}
0 commit comments