Merge branch 'jmc-7491' into 'main'

fix(issue list): change output flag back to output-format

Closes #7491

See merge request https://gitlab.com/gitlab-org/cli/-/merge_requests/1425

Merged-by: Gary Holtz <gholtz@gitlab.com>
Approved-by: Patrick Bajao <ebajao@gitlab.com>
Approved-by: Shekhar Patnaik <spatnaik@gitlab.com>
Reviewed-by: Patrick Bajao <ebajao@gitlab.com>
Reviewed-by: Jay McCure <jmccure@gitlab.com>
Co-authored-by: Jay McCure <jmccure@gitlab.com>
This commit is contained in:
Gary Holtz 2024-04-18 17:55:51 +00:00
commit 0a1bdd618f
4 changed files with 17 additions and 5 deletions

View File

@ -53,6 +53,7 @@ type ListOptions struct {
ListType string
TitleQualifier string
OutputFormat string
Output string
IO *iostreams.IOStreams
BaseRepo func() (glrepo.Interface, error)
@ -138,10 +139,12 @@ func NewCmdList(f *cmdutils.Factory, runE func(opts *ListOptions) error, issueTy
issueListCmd.Flags().BoolVarP(&opts.All, "all", "A", false, fmt.Sprintf("Get all %ss", issueType))
issueListCmd.Flags().BoolVarP(&opts.Closed, "closed", "c", false, fmt.Sprintf("Get only closed %ss", issueType))
issueListCmd.Flags().BoolVarP(&opts.Confidential, "confidential", "C", false, fmt.Sprintf("Filter by confidential %ss", issueType))
issueListCmd.Flags().StringVarP(&opts.OutputFormat, "output", "F", "details", "One of 'details', 'ids', 'urls' or 'json'")
issueListCmd.Flags().StringVarP(&opts.OutputFormat, "output-format", "F", "details", "One of 'details', 'ids', 'urls'")
issueListCmd.Flags().StringVarP(&opts.Output, "output", "O", "text", "One of 'text' or 'json'")
issueListCmd.Flags().IntVarP(&opts.Page, "page", "p", 1, "Page number")
issueListCmd.Flags().IntVarP(&opts.PerPage, "per-page", "P", 30, "Number of items to list per page.")
issueListCmd.PersistentFlags().StringP("group", "g", "", "Select a group/subgroup. This option is ignored if a repo argument is set.")
issueListCmd.MarkFlagsMutuallyExclusive("output", "output-format")
if issueType == issuable.TypeIssue {
issueListCmd.Flags().StringVarP(&opts.IssueType, "issue-type", "t", "", "Filter issue by its type {issue|incident|test_case}")
@ -263,7 +266,7 @@ func listRun(opts *ListOptions) error {
title.ListActionType = opts.ListType
title.CurrentPageTotal = len(issues)
if opts.OutputFormat == "json" {
if opts.Output == "json" {
issueListJSON, _ := json.Marshal(issues)
fmt.Fprintln(opts.IO.StdOut, string(issueListJSON))
return nil

View File

@ -359,7 +359,7 @@ func TestIssueListJSON(t *testing.T) {
fakeHTTP.RegisterResponder(http.MethodGet, "/projects/OWNER/REPO/issues",
httpmock.NewFileResponse(http.StatusOK, "./testdata/issueListFull.json"))
output, err := runCommand("issue", fakeHTTP, true, "-F json", nil, "")
output, err := runCommand("issue", fakeHTTP, true, "--output json", nil, "")
if err != nil {
t.Errorf("error running command `issue list -F json`: %v", err)
}
@ -378,3 +378,10 @@ func TestIssueListJSON(t *testing.T) {
assert.JSONEq(t, expectedOut, output.String())
assert.Empty(t, output.Stderr())
}
func TestIssueListMutualOutputFlags(t *testing.T) {
_, err := runCommand("issue", nil, true, "--output json --output-format ids", nil, "")
assert.NotNil(t, err)
assert.EqualError(t, err, "if any flags in the group [output output-format] are set none of the others can be; [output output-format] were all set")
}

View File

@ -48,7 +48,8 @@ glab incident list --milestone release-2.0.0 --opened
--not-assignee strings Filter incident by not being assigneed to <username>
--not-author strings Filter by not being by author(s) <username>
--not-label strings Filter incident by lack of label <name>
-F, --output string One of 'details', 'ids', 'urls' or 'json' (default "details")
-O, --output string One of 'text' or 'json' (default "text")
-F, --output-format string One of 'details', 'ids', 'urls' (default "details")
-p, --page int Page number (default 1)
-P, --per-page int Number of items to list per page. (default 30)
-R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL

View File

@ -49,7 +49,8 @@ glab issue list --milestone release-2.0.0 --opened
--not-assignee strings Filter issue by not being assigneed to <username>
--not-author strings Filter by not being by author(s) <username>
--not-label strings Filter issue by lack of label <name>
-F, --output string One of 'details', 'ids', 'urls' or 'json' (default "details")
-O, --output string One of 'text' or 'json' (default "text")
-F, --output-format string One of 'details', 'ids', 'urls' (default "details")
-p, --page int Page number (default 1)
-P, --per-page int Number of items to list per page. (default 30)
-R, --repo OWNER/REPO Select another repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format or full URL or git URL