Skip to content

Commit 8b73951

Browse files
babakksmaxbeizerCopilot
committed
feat(discussion list): add discussion list command
Add `gh discussion list` with support for: - Filtering by category, state, author, and labels - Search keyword matching - Table and JSON output formats - Web mode (opens browser with filters) - Pagination via --limit flag Also adds the discussion command group scaffolding and root wiring. Co-authored-by: Max Beizer <max.beizer@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d3a1538 commit 8b73951

4 files changed

Lines changed: 1016 additions & 0 deletions

File tree

‎pkg/cmd/discussion/discussion.go‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package discussion
2+
3+
import (
4+
"github.com/MakeNowJust/heredoc"
5+
cmdCreate "github.com/cli/cli/v2/pkg/cmd/discussion/create"
6+
cmdEdit "github.com/cli/cli/v2/pkg/cmd/discussion/edit"
7+
cmdList "github.com/cli/cli/v2/pkg/cmd/discussion/list"
8+
cmdView "github.com/cli/cli/v2/pkg/cmd/discussion/view"
9+
"github.com/cli/cli/v2/pkg/cmdutil"
10+
"github.com/spf13/cobra"
11+
)
12+
13+
// NewCmdDiscussion returns the top-level "discussion" command.
14+
func NewCmdDiscussion(f *cmdutil.Factory) *cobra.Command {
15+
cmd := &cobra.Command{
16+
Use: "discussion <command>",
17+
Short: "Work with GitHub Discussions (preview)",
18+
Long: heredoc.Doc(`
19+
Working with discussions in the GitHub CLI is in preview and subject to change without notice.
20+
`),
21+
Example: heredoc.Doc(`
22+
$ gh discussion list
23+
$ gh discussion create --category "General" --title "Hello"
24+
$ gh discussion view 123
25+
`),
26+
Annotations: map[string]string{
27+
"help:arguments": heredoc.Doc(`
28+
A discussion can be supplied as argument in any of the following formats:
29+
- by number, e.g. "123"; or
30+
- by URL, e.g. "https://github.com/OWNER/REPO/discussions/123".
31+
`),
32+
},
33+
GroupID: "core",
34+
}
35+
36+
cmdutil.EnableRepoOverride(cmd, f)
37+
38+
cmdutil.AddGroup(cmd, "General commands",
39+
cmdCreate.NewCmdCreate(f, nil),
40+
cmdList.NewCmdList(f, nil),
41+
)
42+
43+
cmdutil.AddGroup(cmd, "Targeted commands",
44+
cmdEdit.NewCmdEdit(f, nil),
45+
cmdView.NewCmdView(f, nil),
46+
)
47+
48+
return cmd
49+
}

0 commit comments

Comments
 (0)