Introduce the pkg/cmd/discussion/ package with: - DiscussionClient interface and domain types (client/) - Generated mock via moq (client/) - Factory function for lazy client creation (shared/) - JSON field definitions for --json output (shared/) - Root 'discussion' command registered in the core group The interface defines all planned operations (list, search, get, create, update, close, reopen, comment, lock, unlock, mark-answer, unmark-answer) with stub implementations that will be replaced as each subcommand is added in subsequent PRs. Domain types are intentionally separate from API types per review guidance. No JSON struct tags are used; serialization is handled by ExportData methods. Refs: cli/cli#12810, github/gh-cli-and-desktop#115 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
21 lines
731 B
Go
21 lines
731 B
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"
|
|
)
|
|
|
|
// 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
|
|
}
|
|
}
|