MCPcopy Create free account
hub / github.com/cli/cli / NewCmdView

Function NewCmdView

pkg/cmd/discussion/view/view.go:96–221  ·  view source on GitHub ↗

NewCmdView creates the "discussion view" command.

(f *cmdutil.Factory, runF func(*ViewOptions) error)

Source from the content-addressed store, hash-verified

94
95// NewCmdView creates the "discussion view" command.
96func NewCmdView(f *cmdutil.Factory, runF func(*ViewOptions) error) *cobra.Command {
97 opts := &ViewOptions{
98 IO: f.IOStreams,
99 Browser: f.Browser,
100 Now: time.Now,
101 }
102
103 cmd := &cobra.Command{
104 Use: "view {<number> | <discussion-url> | <comment-id> | <comment-url>} [flags]",
105 Short: "View a discussion (preview)",
106 Long: heredoc.Docf(`
107 Display the title, body, and other information about a discussion.
108
109 To see the comments on a discussion, pass %[1]s--comments%[1]s. A few latest replies
110 of each comment will also be retrieved regardless of the selected ordering.
111 When %[1]s--comments%[1]s is used, terminal output includes the discussion details and comments.
112 When output is piped or redirected, only the comments are printed.
113
114 To see the full reply thread of a single comment, pass a comment node ID or
115 comment URL as the argument instead of a discussion
116 (e.g., %[1]shttps://github.com/OWNER/REPO/discussions/123#discussioncomment-456%[1]s).
117
118 Pagination and ordering can be controlled via %[1]s--order%[1]s, %[1]s--limit%[1]s, and %[1]s--after%[1]s flags.
119
120 Use %[1]s--web%[1]s to open the discussion or comment in a web browser instead.
121 `, "`"),
122 Example: heredoc.Doc(`
123 # View a discussion by number
124 $ gh discussion view 123
125
126 # View a discussion by URL
127 $ gh discussion view https://github.com/OWNER/REPO/discussions/123
128
129 # View with comments
130 $ gh discussion view 123 --comments
131
132 # View with oldest comments first
133 $ gh discussion view 123 --comments --order oldest
134
135 # Limit to 10 comments
136 $ gh discussion view 123 --comments --limit 10
137
138 # Fetch the next page of comments
139 $ gh discussion view 123 --comments --after CURSOR
140
141 # View the reply thread of a comment by node ID
142 $ gh discussion view DC_abc123
143
144 # View the reply thread of a comment by URL
145 $ gh discussion view 'https://github.com/OWNER/REPO/discussions/123#discussioncomment-456'
146
147 # Paginate through replies
148 $ gh discussion view DC_abc123 --limit 10 --after CURSOR
149
150 # Open in browser
151 $ gh discussion view 123 --web
152 `),
153 Args: cobra.ExactArgs(1),

Callers 1

TestNewCmdViewFunction · 0.70

Calls 11

MutuallyExclusiveFunction · 0.92
FlagErrorWrapFunction · 0.92
FlagErrorfFunction · 0.92
DiscussionClientFuncFunction · 0.92
EnableRepoOverrideFunction · 0.92
StringEnumFlagFunction · 0.92
AddJSONFlagsFunction · 0.92
needsCommentsFunction · 0.85
ChangedMethod · 0.80
viewRunFunction · 0.70

Tested by 1

TestNewCmdViewFunction · 0.56