From 6470d9e57462bc8d3a30583cf146d4f466e2d5f7 Mon Sep 17 00:00:00 2001 From: Lance Ball Date: Fri, 11 Dec 2020 09:32:30 -0500 Subject: [PATCH] fix: change --format flag to --output for list and describe commands (#248) Fixes: https://github.com/boson-project/func/issues/223 Signed-off-by: Lance Ball --- cmd/describe.go | 16 ++++++++-------- cmd/list.go | 22 +++++++++++----------- docs/commands.md | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cmd/describe.go b/cmd/describe.go index c69c59705..71c772d49 100644 --- a/cmd/describe.go +++ b/cmd/describe.go @@ -18,10 +18,10 @@ import ( func init() { root.AddCommand(describeCmd) describeCmd.Flags().StringP("namespace", "n", "", "Namespace of the function. By default, the namespace in func.yaml is used or the actual active namespace if not set in the configuration. (Env: $FUNC_NAMESPACE)") - describeCmd.Flags().StringP("format", "f", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_FORMAT)") + describeCmd.Flags().StringP("output", "o", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_OUTPUT)") describeCmd.Flags().StringP("path", "p", cwd(), "Path to the project directory (Env: $FUNC_PATH)") - err := describeCmd.RegisterFlagCompletionFunc("format", CompleteOutputFormatList) + err := describeCmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList) if err != nil { fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err) } @@ -39,12 +39,12 @@ the current directory or from the directory specified with --path. # Show the details of a function as declared in the local func.yaml kn func describe -# Show the details of the function in YAML format for the function in the myotherfunc directory -kn func describe --format yaml --path myotherfunc +# Show the details of the function in the myotherfunc directory with yaml output +kn func describe --output yaml --path myotherfunc `, SuggestFor: []string{"desc", "get"}, ValidArgsFunction: CompleteFunctionList, - PreRunE: bindEnv("namespace", "format", "path"), + PreRunE: bindEnv("namespace", "output", "path"), RunE: runDescribe, } @@ -77,7 +77,7 @@ func runDescribe(cmd *cobra.Command, args []string) (err error) { } d.Image = function.Image - write(os.Stdout, description(d), config.Format) + write(os.Stdout, description(d), config.Output) return } @@ -87,7 +87,7 @@ func runDescribe(cmd *cobra.Command, args []string) (err error) { type describeConfig struct { Name string Namespace string - Format string + Output string Path string Verbose bool } @@ -100,7 +100,7 @@ func newDescribeConfig(args []string) describeConfig { return describeConfig{ Name: deriveName(name, viper.GetString("path")), Namespace: viper.GetString("namespace"), - Format: viper.GetString("format"), + Output: viper.GetString("output"), Path: viper.GetString("path"), Verbose: viper.GetBool("verbose"), } diff --git a/cmd/list.go b/cmd/list.go index 711add20c..eb45db3f7 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -20,8 +20,8 @@ func init() { root.AddCommand(listCmd) listCmd.Flags().BoolP("all-namespaces", "A", false, "List functions in all namespaces. If set, the --namespace flag is ignored.") listCmd.Flags().StringP("namespace", "n", "", "Namespace of the function to undeploy. By default, the functions of the actual active namespace are listed. (Env: $FUNC_NAMESPACE)") - listCmd.Flags().StringP("format", "f", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_FORMAT)") - err := listCmd.RegisterFlagCompletionFunc("format", CompleteOutputFormatList) + listCmd.Flags().StringP("output", "o", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_OUTPUT)") + err := listCmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList) if err != nil { fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err) } @@ -35,17 +35,17 @@ var listCmd = &cobra.Command{ Lists all deployed functions in a given namespace. `, Example: ` -# List all functions in the current namespace in human readable format +# List all functions in the current namespace with human readable output kn func list -# List all functions in the 'test' namespace in yaml format -kn func list --namespace test --format yaml +# List all functions in the 'test' namespace with yaml output +kn func list --namespace test --output yaml -# List all functions in all namespaces in JSON format -kn func list --all-namespaces --format json +# List all functions in all namespaces with JSON output +kn func list --all-namespaces --output json `, SuggestFor: []string{"ls", "lsit"}, - PreRunE: bindEnv("namespace", "format"), + PreRunE: bindEnv("namespace", "output"), RunE: runList, } @@ -75,7 +75,7 @@ func runList(cmd *cobra.Command, args []string) (err error) { return } - write(os.Stdout, listItems(items), config.Format) + write(os.Stdout, listItems(items), config.Output) return } @@ -85,14 +85,14 @@ func runList(cmd *cobra.Command, args []string) (err error) { type listConfig struct { Namespace string - Format string + Output string Verbose bool } func newListConfig() listConfig { return listConfig{ Namespace: viper.GetString("namespace"), - Format: viper.GetString("format"), + Output: viper.GetString("output"), Verbose: viper.GetBool("verbose"), } } diff --git a/docs/commands.md b/docs/commands.md index 7db3fa391..af723745f 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -80,13 +80,13 @@ Prints the name, route and any event subscriptions for a deployed Function. The Similar `kn` command: `kn service describe NAME [flags]`. This flag provides a lot of nice information not available in `func describe`, such as revisions, age, annotations and labels. This command should be renamed to make it distinct from `kn` - e.g. `func status`. ```console -func describe [-f -n -p ] +func describe [-o -n -p ] ``` When run as a `kn` plugin. ```console -kn func describe [-f -n -p ] +kn func describe [-o -n -p ] ``` ## `list`