Skip to content

Commit 6470d9e

Browse files
authored
fix: change --format flag to --output for list and describe commands (#248)
Fixes: #223 Signed-off-by: Lance Ball <lball@redhat.com>
1 parent 5430637 commit 6470d9e

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

cmd/describe.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ import (
1818
func init() {
1919
root.AddCommand(describeCmd)
2020
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)")
21-
describeCmd.Flags().StringP("format", "f", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_FORMAT)")
21+
describeCmd.Flags().StringP("output", "o", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_OUTPUT)")
2222
describeCmd.Flags().StringP("path", "p", cwd(), "Path to the project directory (Env: $FUNC_PATH)")
2323

24-
err := describeCmd.RegisterFlagCompletionFunc("format", CompleteOutputFormatList)
24+
err := describeCmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList)
2525
if err != nil {
2626
fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err)
2727
}
@@ -39,12 +39,12 @@ the current directory or from the directory specified with --path.
3939
# Show the details of a function as declared in the local func.yaml
4040
kn func describe
4141
42-
# Show the details of the function in YAML format for the function in the myotherfunc directory
43-
kn func describe --format yaml --path myotherfunc
42+
# Show the details of the function in the myotherfunc directory with yaml output
43+
kn func describe --output yaml --path myotherfunc
4444
`,
4545
SuggestFor: []string{"desc", "get"},
4646
ValidArgsFunction: CompleteFunctionList,
47-
PreRunE: bindEnv("namespace", "format", "path"),
47+
PreRunE: bindEnv("namespace", "output", "path"),
4848
RunE: runDescribe,
4949
}
5050

@@ -77,7 +77,7 @@ func runDescribe(cmd *cobra.Command, args []string) (err error) {
7777
}
7878
d.Image = function.Image
7979

80-
write(os.Stdout, description(d), config.Format)
80+
write(os.Stdout, description(d), config.Output)
8181
return
8282
}
8383

@@ -87,7 +87,7 @@ func runDescribe(cmd *cobra.Command, args []string) (err error) {
8787
type describeConfig struct {
8888
Name string
8989
Namespace string
90-
Format string
90+
Output string
9191
Path string
9292
Verbose bool
9393
}
@@ -100,7 +100,7 @@ func newDescribeConfig(args []string) describeConfig {
100100
return describeConfig{
101101
Name: deriveName(name, viper.GetString("path")),
102102
Namespace: viper.GetString("namespace"),
103-
Format: viper.GetString("format"),
103+
Output: viper.GetString("output"),
104104
Path: viper.GetString("path"),
105105
Verbose: viper.GetBool("verbose"),
106106
}

cmd/list.go

+11-11
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ func init() {
2020
root.AddCommand(listCmd)
2121
listCmd.Flags().BoolP("all-namespaces", "A", false, "List functions in all namespaces. If set, the --namespace flag is ignored.")
2222
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)")
23-
listCmd.Flags().StringP("format", "f", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_FORMAT)")
24-
err := listCmd.RegisterFlagCompletionFunc("format", CompleteOutputFormatList)
23+
listCmd.Flags().StringP("output", "o", "human", "Output format (human|plain|json|xml|yaml) (Env: $FUNC_OUTPUT)")
24+
err := listCmd.RegisterFlagCompletionFunc("output", CompleteOutputFormatList)
2525
if err != nil {
2626
fmt.Println("internal: error while calling RegisterFlagCompletionFunc: ", err)
2727
}
@@ -35,17 +35,17 @@ var listCmd = &cobra.Command{
3535
Lists all deployed functions in a given namespace.
3636
`,
3737
Example: `
38-
# List all functions in the current namespace in human readable format
38+
# List all functions in the current namespace with human readable output
3939
kn func list
4040
41-
# List all functions in the 'test' namespace in yaml format
42-
kn func list --namespace test --format yaml
41+
# List all functions in the 'test' namespace with yaml output
42+
kn func list --namespace test --output yaml
4343
44-
# List all functions in all namespaces in JSON format
45-
kn func list --all-namespaces --format json
44+
# List all functions in all namespaces with JSON output
45+
kn func list --all-namespaces --output json
4646
`,
4747
SuggestFor: []string{"ls", "lsit"},
48-
PreRunE: bindEnv("namespace", "format"),
48+
PreRunE: bindEnv("namespace", "output"),
4949
RunE: runList,
5050
}
5151

@@ -75,7 +75,7 @@ func runList(cmd *cobra.Command, args []string) (err error) {
7575
return
7676
}
7777

78-
write(os.Stdout, listItems(items), config.Format)
78+
write(os.Stdout, listItems(items), config.Output)
7979

8080
return
8181
}
@@ -85,14 +85,14 @@ func runList(cmd *cobra.Command, args []string) (err error) {
8585

8686
type listConfig struct {
8787
Namespace string
88-
Format string
88+
Output string
8989
Verbose bool
9090
}
9191

9292
func newListConfig() listConfig {
9393
return listConfig{
9494
Namespace: viper.GetString("namespace"),
95-
Format: viper.GetString("format"),
95+
Output: viper.GetString("output"),
9696
Verbose: viper.GetBool("verbose"),
9797
}
9898
}

docs/commands.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ Prints the name, route and any event subscriptions for a deployed Function. The
8080
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`.
8181

8282
```console
83-
func describe [-f <format> -n <namespace> -p <path>]
83+
func describe [-o <output> -n <namespace> -p <path>]
8484
```
8585

8686
When run as a `kn` plugin.
8787

8888
```console
89-
kn func describe [-f <format> -n <namespace> -p <path>]
89+
kn func describe [-o <output> -n <namespace> -p <path>]
9090
```
9191

9292
## `list`

0 commit comments

Comments
 (0)