Add --limit and --after flags for paginating through discussion comments. Cursor output is shown in TTY (hint message), raw (next: field), and JSON. Change GetWithComments to accept 'after' cursor and 'newest' bool instead of order string. Implement forward/backward cursor-based pagination in GraphQL queries depending on comment order. Change Replies from []DiscussionComment to DiscussionCommentList with Direction field. Display direction-aware messages (newer/older) for both comments and replies. Move DiscussionFields and reactionGroupList from shared to view package. Delete shared/display.go. Add 7 new pagination tests and update existing test fixtures. 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
|
|
}
|
|
}
|