- Rewrite GetByNumber to use strongly-typed GraphQL query instead of removed raw string interpolation (discussionFields/discussionNode) - Fix State string references to use Closed bool throughout view.go - Fix DiscussionAuthor → DiscussionActor type rename in tests - Add ReactionGroups field to Discussion domain type and ExportData - Add computed "state" field to ExportData for JSON output - Add shared.DiscussionFields for view command's --json flag - Regenerate client mock Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
46 lines
1.1 KiB
Go
46 lines
1.1 KiB
Go
// Package shared provides factory functions, field definitions, and display
|
|
// helpers used across discussion subcommands.
|
|
package shared
|
|
|
|
import (
|
|
"github.com/cli/cli/v2/pkg/cmd/discussion/client"
|
|
"github.com/cli/cli/v2/pkg/cmdutil"
|
|
)
|
|
|
|
// DiscussionFields lists all field names available for --json output
|
|
// on discussion commands that return a full discussion (e.g. view).
|
|
var DiscussionFields = []string{
|
|
"id",
|
|
"number",
|
|
"title",
|
|
"body",
|
|
"url",
|
|
"closed",
|
|
"state",
|
|
"stateReason",
|
|
"author",
|
|
"category",
|
|
"labels",
|
|
"answered",
|
|
"answerChosenAt",
|
|
"answerChosenBy",
|
|
"comments",
|
|
"reactionGroups",
|
|
"createdAt",
|
|
"updatedAt",
|
|
"closedAt",
|
|
"locked",
|
|
}
|
|
|
|
// DiscussionClientFunc returns a factory function that creates a DiscussionClient
|
|
// from the given Factory. The returned function is intended to be stored in
|
|
// command Options structs and called lazily inside RunE.
|
|
func DiscussionClientFunc(f *cmdutil.Factory) func() (client.DiscussionClient, error) {
|
|
return func() (client.DiscussionClient, error) {
|
|
httpClient, err := f.HttpClient()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return client.NewDiscussionClient(httpClient), nil
|
|
}
|
|
}
|