cli/pkg/cmd/discussion/discussion.go
Max Beizer e471f3f8f1
feat: add gh discussion create command
Implements the 'gh discussion create' CLI command, wiring up the
already-merged Create client method. Supports:
- --title/-t, --body/-b, --category/-c, --label/-l flags
- Interactive prompting when TTY and required flags are missing
- Non-TTY mode requiring all flags
- TTY and non-TTY output formats

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-06 14:52:07 -05:00

47 lines
1.3 KiB
Go

package discussion
import (
"github.com/MakeNowJust/heredoc"
cmdCreate "github.com/cli/cli/v2/pkg/cmd/discussion/create"
cmdList "github.com/cli/cli/v2/pkg/cmd/discussion/list"
cmdView "github.com/cli/cli/v2/pkg/cmd/discussion/view"
"github.com/cli/cli/v2/pkg/cmdutil"
"github.com/spf13/cobra"
)
// NewCmdDiscussion returns the top-level "discussion" command.
func NewCmdDiscussion(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "discussion <command>",
Short: "Work with GitHub Discussions (preview)",
Long: heredoc.Doc(`
Working with discussions in the GitHub CLI is in preview and subject to change without notice.
`),
Example: heredoc.Doc(`
$ gh discussion list
$ gh discussion create --category "General" --title "Hello"
$ gh discussion view 123
`),
Annotations: map[string]string{
"help:arguments": heredoc.Doc(`
A discussion can be supplied as argument in any of the following formats:
- by number, e.g. "123"; or
- by URL, e.g. "https://github.com/OWNER/REPO/discussions/123".
`),
},
GroupID: "core",
}
cmdutil.EnableRepoOverride(cmd, f)
cmdutil.AddGroup(cmd, "General commands",
cmdCreate.NewCmdCreate(f, nil),
cmdList.NewCmdList(f, nil),
)
cmdutil.AddGroup(cmd, "Targeted commands",
cmdView.NewCmdView(f, nil),
)
return cmd
}