Skip to content

Commit

Permalink
reorganize flags; marked for "kong" subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Jul 17, 2023
1 parent 6acdd6d commit 4e37600
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,30 @@ It can be used to export, import, or sync entities to Kong.`,
}
cobra.OnInitialize(initConfig)

// global flags
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "",
"Config file (default is $HOME/.deck.yaml).")

rootCmd.PersistentFlags().Int("verbose", 0,
"Enable verbose logging levels\n"+
"Sets the verbosity level of log output (higher is more verbose).")
viper.BindPFlag("verbose",
rootCmd.PersistentFlags().Lookup("verbose"))

rootCmd.PersistentFlags().Bool("no-color", false,
"Disable colorized output")
viper.BindPFlag("no-color",
rootCmd.PersistentFlags().Lookup("no-color"))

rootCmd.PersistentFlags().Bool("analytics", true,
"Share anonymized data to help improve decK.\n"+
"Use `--analytics=false` to disable this.")
viper.BindPFlag("analytics",
rootCmd.PersistentFlags().Lookup("analytics"))

// TODO: everything below are online flags to be moved to the "kong" subcommand
// moving them now would break to top-level commands (sync, diff, etc) we still
// need for backward compatibility.
rootCmd.PersistentFlags().String("kong-addr", defaultKongURL,
"HTTP address of Kong's Admin API.\n"+
"This value can also be set using the environment variable DECK_KONG_ADDR\n"+
Expand Down Expand Up @@ -101,17 +122,6 @@ It can be used to export, import, or sync entities to Kong.`,
viper.BindPFlag("ca-cert-file",
rootCmd.PersistentFlags().Lookup("ca-cert-file"))

rootCmd.PersistentFlags().Int("verbose", 0,
"Enable verbose logging levels\n"+
"Sets the verbosity level of log output (higher is more verbose).")
viper.BindPFlag("verbose",
rootCmd.PersistentFlags().Lookup("verbose"))

rootCmd.PersistentFlags().Bool("no-color", false,
"Disable colorized output")
viper.BindPFlag("no-color",
rootCmd.PersistentFlags().Lookup("no-color"))

rootCmd.PersistentFlags().Bool("skip-workspace-crud", false,
"Skip API calls related to Workspaces (Kong Enterprise only).")
viper.BindPFlag("skip-workspace-crud",
Expand All @@ -124,12 +134,6 @@ It can be used to export, import, or sync entities to Kong.`,
viper.BindPFlag("kong-cookie-jar-path",
rootCmd.PersistentFlags().Lookup("kong-cookie-jar-path"))

rootCmd.PersistentFlags().Bool("analytics", true,
"Share anonymized data to help improve decK.\n"+
"Use `--analytics=false` to disable this.")
viper.BindPFlag("analytics",
rootCmd.PersistentFlags().Lookup("analytics"))

rootCmd.PersistentFlags().Int("timeout", 10,
"Set a request timeout for the client to connect with Kong (in seconds).")
viper.BindPFlag("timeout",
Expand Down

0 comments on commit 4e37600

Please sign in to comment.