Enhance flag descriptions

This commit is contained in:
Juan Carlos Mejías Rodríguez 2019-08-06 18:51:56 -04:00
parent faf021e863
commit c4e2f0145f
8 changed files with 24 additions and 23 deletions

View File

@ -2,9 +2,10 @@ package cmd
import (
"fmt"
"github.com/spf13/viper"
"sort"
"github.com/spf13/viper"
"github.com/spf13/cobra"
)
@ -35,6 +36,6 @@ var configListCmd = &cobra.Command{
func init() {
configCmd.AddCommand(configListCmd)
configListCmd.Flags().Bool("keys", false, "list only keys")
configListCmd.Flags().Bool("keys", false, "Only list keys.")
viper.BindPFlag("config.list.keys", configListCmd.Flags().Lookup("keys"))
}

View File

@ -88,6 +88,6 @@ var endpointListCmd = &cobra.Command{
func init() {
endpointCmd.AddCommand(endpointListCmd)
endpointListCmd.Flags().String("format", "", "format output using a Go template")
endpointListCmd.Flags().String("format", "", "Format output using a Go template.")
viper.BindPFlag("endpoint.list.format", endpointListCmd.Flags().Lookup("format"))
}

View File

@ -38,6 +38,6 @@ var loginCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(loginCmd)
loginCmd.Flags().Bool("print", false, "prints retrieved auth token")
loginCmd.Flags().Bool("print", false, "Print retrieved auth token.")
viper.BindPFlag("login.print", loginCmd.Flags().Lookup("print"))
}

View File

@ -40,14 +40,14 @@ func init() {
// Cobra supports persistent flags, which, if defined here,
// will be global for your application.
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.psu.yaml)")
rootCmd.PersistentFlags().StringP("log-level", "v", "info", "log level")
rootCmd.PersistentFlags().BoolP("insecure", "i", false, "skip Portainer SSL certificate verification")
rootCmd.PersistentFlags().StringP("url", "l", "", "Portainer url")
rootCmd.PersistentFlags().StringP("user", "u", "", "Portainer user")
rootCmd.PersistentFlags().StringP("password", "p", "", "Portainer password")
rootCmd.PersistentFlags().StringP("auth-token", "A", "", "Portainer auth token")
rootCmd.PersistentFlags().DurationP("timeout", "t", 0, "waiting time before aborting (like 100ms, 30s, 1h20m)")
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "Config file. (default \"$HOME/.psu.yaml)\"")
rootCmd.PersistentFlags().StringP("log-level", "v", "info", "Log level. One of trace, debug, info, warning, error, fatal or panic.")
rootCmd.PersistentFlags().BoolP("insecure", "i", false, "Skip Portainer SSL certificate verification.")
rootCmd.PersistentFlags().StringP("url", "l", "", "Portainer url.")
rootCmd.PersistentFlags().StringP("user", "u", "", "Portainer user.")
rootCmd.PersistentFlags().StringP("password", "p", "", "Portainer password.")
rootCmd.PersistentFlags().StringP("auth-token", "A", "", "Portainer auth token.")
rootCmd.PersistentFlags().DurationP("timeout", "t", 0, "Waiting time before aborting (like 100ms, 30s, 1h20m).")
viper.BindPFlag("config", rootCmd.PersistentFlags().Lookup("config"))
viper.BindPFlag("log-level", rootCmd.PersistentFlags().Lookup("log-level"))
viper.BindPFlag("insecure", rootCmd.PersistentFlags().Lookup("insecure"))

View File

@ -130,11 +130,11 @@ var stackDeployCmd = &cobra.Command{
func init() {
stackCmd.AddCommand(stackDeployCmd)
stackDeployCmd.Flags().StringP("stack-file", "c", "", "path to a file with the content of the stack")
stackDeployCmd.Flags().String("endpoint", "1", "endpoint ID")
stackDeployCmd.Flags().StringP("env-file", "e", "", "path to a file with environment variables used during stack deployment")
stackDeployCmd.Flags().Bool("replace-env", false, "replace environment variables instead of merging them")
stackDeployCmd.Flags().BoolP("prune", "r", false, "prune services that are no longer referenced (only available for Swarm stacks)")
stackDeployCmd.Flags().StringP("stack-file", "c", "", "Path to a file with the content of the stack.")
stackDeployCmd.Flags().String("endpoint", "1", "Endpoint ID.")
stackDeployCmd.Flags().StringP("env-file", "e", "", "Path to a file with environment variables used during stack deployment.")
stackDeployCmd.Flags().Bool("replace-env", false, "Replace environment variables instead of merging them.")
stackDeployCmd.Flags().BoolP("prune", "r", false, "Prune services that are no longer referenced (only available for Swarm stacks).")
viper.BindPFlag("stack.deploy.stack-file", stackDeployCmd.Flags().Lookup("stack-file"))
viper.BindPFlag("stack.deploy.endpoint", stackDeployCmd.Flags().Lookup("endpoint"))
viper.BindPFlag("stack.deploy.env-file", stackDeployCmd.Flags().Lookup("env-file"))

View File

@ -79,10 +79,10 @@ var stackListCmd = &cobra.Command{
func init() {
stackCmd.AddCommand(stackListCmd)
stackListCmd.Flags().String("swarm", "", "filter by swarm ID")
stackListCmd.Flags().String("endpoint", "", "filter by endpoint ID")
stackListCmd.Flags().BoolP("quiet", "q", false, "only display stack names")
stackListCmd.Flags().String("format", "", "format output using a Go template")
stackListCmd.Flags().String("swarm", "", "Filter by swarm ID.")
stackListCmd.Flags().String("endpoint", "", "Filter by endpoint ID.")
stackListCmd.Flags().BoolP("quiet", "q", false, "Only display stack names.")
stackListCmd.Flags().String("format", "", "Format output using a Go template.")
viper.BindPFlag("stack.list.swarm", stackListCmd.Flags().Lookup("swarm"))
viper.BindPFlag("stack.list.endpoint", stackListCmd.Flags().Lookup("endpoint"))
viper.BindPFlag("stack.list.quiet", stackListCmd.Flags().Lookup("quiet"))

View File

@ -51,6 +51,6 @@ var stackRemoveCmd = &cobra.Command{
func init() {
stackCmd.AddCommand(stackRemoveCmd)
stackRemoveCmd.Flags().Bool("strict", false, "fail if stack does not exist")
stackRemoveCmd.Flags().Bool("strict", false, "Fail if stack does not exist.")
viper.BindPFlag("stack.remove.strict", stackRemoveCmd.Flags().Lookup("strict"))
}

View File

@ -56,6 +56,6 @@ var statusCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(statusCmd)
statusCmd.Flags().String("format", "", "format output using a Go template")
statusCmd.Flags().String("format", "", "Format output using a Go template.")
viper.BindPFlag("status.format", statusCmd.Flags().Lookup("format"))
}