From 5d2cf3ef7ec197aeb4bf5d009e71baab73c15ca1 Mon Sep 17 00:00:00 2001 From: ahorine Date: Wed, 4 Sep 2024 16:33:42 -0400 Subject: [PATCH] feat: Added 's' shorthand to operation-scope flags The operation-scope flag gets used a lot when examining resources on member clusters. The 's' shorthand was added to improve user QoL. Signed-off-by: ahorine --- pkg/karmadactl/apiresources/apiresources.go | 2 +- pkg/karmadactl/apiresources/apiversions.go | 2 +- pkg/karmadactl/attach/attach.go | 2 +- pkg/karmadactl/describe/describe.go | 2 +- pkg/karmadactl/exec/exec.go | 2 +- pkg/karmadactl/explain/explain.go | 2 +- pkg/karmadactl/get/get.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/karmadactl/apiresources/apiresources.go b/pkg/karmadactl/apiresources/apiresources.go index 2645048513f9..b530862a869b 100644 --- a/pkg/karmadactl/apiresources/apiresources.go +++ b/pkg/karmadactl/apiresources/apiresources.go @@ -71,7 +71,7 @@ func NewCmdAPIResources(f util.Factory, parentCommand string, ioStreams generici } o.OperationScope = options.KarmadaControlPlane - cmd.Flags().Var(&o.OperationScope, "operation-scope", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") + cmd.Flags().VarP(&o.OperationScope, "operation-scope", "s", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") cmd.Flags().StringVar(&o.Cluster, "cluster", "", "Used to specify a target member cluster and only takes effect when the command's operation scope is members, for example: --operation-scope=members --cluster=member1") cmd.Flags().BoolVar(&o.NoHeaders, "no-headers", o.NoHeaders, "When using the default or custom-column output format, don't print headers (default print headers).") cmd.Flags().StringVarP(&o.Output, "output", "o", o.Output, `Output format. One of: (wide, name).`) diff --git a/pkg/karmadactl/apiresources/apiversions.go b/pkg/karmadactl/apiresources/apiversions.go index 3aede352f83b..42ca79d7e5a3 100644 --- a/pkg/karmadactl/apiresources/apiversions.go +++ b/pkg/karmadactl/apiresources/apiversions.go @@ -59,7 +59,7 @@ func NewCmdAPIVersions(f util.Factory, parentCommand string, ioStreams genericio } o.OperationScope = options.KarmadaControlPlane - cmd.Flags().Var(&o.OperationScope, "operation-scope", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") + cmd.Flags().VarP(&o.OperationScope, "operation-scope", "s", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") cmd.Flags().StringVar(&o.Cluster, "cluster", "", "Used to specify a target member cluster and only takes effect when the command's operation scope is members, for example: --operation-scope=members --cluster=member1") return cmd } diff --git a/pkg/karmadactl/attach/attach.go b/pkg/karmadactl/attach/attach.go index d92227254a48..57e0b0882619 100644 --- a/pkg/karmadactl/attach/attach.go +++ b/pkg/karmadactl/attach/attach.go @@ -83,7 +83,7 @@ func NewCmdAttach(f util.Factory, parentCommand string, streams genericiooptions cmd.Flags().BoolVarP(&o.TTY, "tty", "t", o.TTY, "Stdin is a TTY") cmd.Flags().BoolVarP(&o.Quiet, "quiet", "q", o.Quiet, "Only print output from the remote session") cmd.Flags().StringVarP(options.DefaultConfigFlags.Namespace, "namespace", "n", *options.DefaultConfigFlags.Namespace, "If present, the namespace scope for this CLI request") - cmd.Flags().Var(&o.OperationScope, "operation-scope", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") + cmd.Flags().VarP(&o.OperationScope, "operation-scope", "s", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") cmd.Flags().StringVar(&o.Cluster, "cluster", "", "Used to specify a target member cluster and only takes effect when the command's operation scope is members, for example: --operation-scope=members --cluster=member1") return cmd } diff --git a/pkg/karmadactl/describe/describe.go b/pkg/karmadactl/describe/describe.go index eefe9ab92c47..dd76c3cb7d20 100644 --- a/pkg/karmadactl/describe/describe.go +++ b/pkg/karmadactl/describe/describe.go @@ -97,7 +97,7 @@ func NewCmdDescribe(f util.Factory, parentCommand string, streams genericiooptio options.AddKubeConfigFlags(flags) o.OperationScope = options.KarmadaControlPlane - flags.Var(&o.OperationScope, "operation-scope", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") + flags.VarP(&o.OperationScope, "operation-scope", "s", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") flags.StringVarP(options.DefaultConfigFlags.Namespace, "namespace", "n", *options.DefaultConfigFlags.Namespace, "If present, the namespace scope for this CLI request") flags.StringVarP(&o.Cluster, "cluster", "C", "", "Used to specify a target member cluster and only takes effect when the command's operation scope is members, for example: --operation-scope=members --cluster=member1") diff --git a/pkg/karmadactl/exec/exec.go b/pkg/karmadactl/exec/exec.go index 0df1be5d62d6..cc749c3f78a0 100644 --- a/pkg/karmadactl/exec/exec.go +++ b/pkg/karmadactl/exec/exec.go @@ -109,7 +109,7 @@ func NewCmdExec(f util.Factory, parentCommand string, streams genericiooptions.I flags.BoolVarP(&o.KubectlExecOptions.Stdin, "stdin", "i", o.KubectlExecOptions.Stdin, "Pass stdin to the container") flags.BoolVarP(&o.KubectlExecOptions.TTY, "tty", "t", o.KubectlExecOptions.TTY, "Stdin is a TTY") flags.BoolVarP(&o.KubectlExecOptions.Quiet, "quiet", "q", o.KubectlExecOptions.Quiet, "Only print output from the remote session") - flags.Var(&o.OperationScope, "operation-scope", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") + flags.VarP(&o.OperationScope, "operation-scope", "s", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") flags.StringVar(&o.Cluster, "cluster", "", "Used to specify a target member cluster and only takes effect when the command's operation scope is members, for example: --operation-scope=members --cluster=member1") return cmd } diff --git a/pkg/karmadactl/explain/explain.go b/pkg/karmadactl/explain/explain.go index 52378a78a74f..c92f6d149130 100644 --- a/pkg/karmadactl/explain/explain.go +++ b/pkg/karmadactl/explain/explain.go @@ -81,7 +81,7 @@ func NewCmdExplain(f util.Factory, parentCommand string, streams genericiooption flags := cmd.Flags() o.OperationScope = options.KarmadaControlPlane - flags.Var(&o.OperationScope, "operation-scope", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") + flags.VarP(&o.OperationScope, "operation-scope", "s", "Used to control the operation scope of the command. The optional values are karmada and members. Defaults to karmada.") flags.BoolVar(&o.Recursive, "recursive", o.Recursive, "When true, print the name of all the fields recursively. Otherwise, print the available fields with their description.") flags.StringVar(&o.APIVersion, "api-version", o.APIVersion, "Use given api-version (group/version) of the resource.") diff --git a/pkg/karmadactl/get/get.go b/pkg/karmadactl/get/get.go index edf66affd92d..9520e897b502 100644 --- a/pkg/karmadactl/get/get.go +++ b/pkg/karmadactl/get/get.go @@ -150,7 +150,7 @@ func NewCmdGet(f util.Factory, parentCommand string, streams genericiooptions.IO flags := cmd.Flags() options.AddKubeConfigFlags(flags) o.OperationScope = options.KarmadaControlPlane - flags.Var(&o.OperationScope, "operation-scope", "Used to control the operation scope of the command. The optional values are karmada, members, and all. Defaults to karmada.") + flags.VarP(&o.OperationScope, "operation-scope", "s", "Used to control the operation scope of the command. The optional values are karmada, members, and all. Defaults to karmada.") flags.StringVarP(options.DefaultConfigFlags.Namespace, "namespace", "n", *options.DefaultConfigFlags.Namespace, "If present, the namespace scope for this CLI request") flags.StringVarP(&o.LabelSelector, "labels", "l", "", "-l=label or -l label") flags.StringSliceVarP(&o.Clusters, "clusters", "C", []string{}, "Used to specify target member clusters and only takes effect when the command's operation scope is members or all, for example: --operation-scope=all --clusters=member1,member2")