From 51ea997db8a6261a4e7ab83bdc62687e64e6de77 Mon Sep 17 00:00:00 2001 From: Clayton Carter Date: Tue, 1 Feb 2022 16:37:51 -0500 Subject: [PATCH] label list: add `--name-only` flag --- cmd/label_list.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/label_list.go b/cmd/label_list.go index 10eee390..6facf159 100644 --- a/cmd/label_list.go +++ b/cmd/label_list.go @@ -27,6 +27,11 @@ var labelListCmd = &cobra.Command{ log.Fatal(err) } + nameOnly, err := cmd.Flags().GetBool("name-only") + if err != nil { + log.Fatal(err) + } + labelSearch = strings.ToLower(labelSearch) labels, err := lab.LabelList(rn) @@ -45,7 +50,7 @@ var labelListCmd = &cobra.Command{ } description := "" - if label.Description != "" { + if !nameOnly && label.Description != "" { description = " - " + label.Description } @@ -79,6 +84,7 @@ func mapLabels(rn string, labelTerms []string) ([]string, error) { } func init() { + labelListCmd.Flags().Bool("name-only", false, "only list label names, not descriptions") labelCmd.AddCommand(labelListCmd) carapace.Gen(labelCmd).PositionalCompletion( action.Remotes(),