[pull] trunk from cli:trunk#159
Merged
Merged
Conversation
Implement a GraphQL client for GitHub Discussions supporting: - List and search discussions with pagination - Get discussion by number with comments - Get paginated comment replies - List repository categories and labels - Create discussions with optional labels - Update discussion title, body, category, and labels - Add/remove labels via separate mutations Includes comprehensive table-driven tests with HTTP mocking. Co-authored-by: Max Beizer <max.beizer@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add shared package with: - ParseDiscussionArg: parses discussion number or URL from CLI args - MatchCategory: case-insensitive category matching by name or slug - ResolveLabels: case-insensitive label name to ID resolution - DiscussionClientFunc: factory helper for lazy client initialization Includes tests for all utilities. Co-authored-by: Max Beizer <max.beizer@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `gh discussion list` with support for: - Filtering by category, state, author, and labels - Search keyword matching - Table and JSON output formats - Web mode (opens browser with filters) - Pagination via --limit flag Also adds the discussion command group scaffolding and root wiring. Co-authored-by: Max Beizer <max.beizer@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `gh discussion view` with support for: - Viewing discussion details with metadata and body - Threaded comment display with --comments flag - Paginated reply fetching with --replies flag - JSON output with --json/--jq/--template flags - Web mode (opens browser) - Accepts discussion number or URL as argument Co-authored-by: Max Beizer <max.beizer@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `gh discussion create` with support for: - Non-interactive creation with --title, --body, --category, --label flags - Interactive mode with prompts for title, body, and category - Body input from file via --body-file (including stdin) - Label resolution (name to ID) before creation - Category validation by name or slug Co-authored-by: Max Beizer <max.beizer@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add `gh discussion edit` with support for: - Non-interactive editing with --title, --body, --body-file, --category flags - Label management with --add-label and --remove-label flags - Interactive mode with multi-select prompts for fields to edit - Flag presence detection (allows setting body to empty string) - Label name to ID resolution via shared.ResolveLabels - Body input from stdin via --body-file - Co-authored-by: Max Beizer <max.beizer@gmail.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix double default in list --limit help text - Wire --body-file flag in create command (symmetric with edit) - Cap comment/reply pagination to maxPageSize (100) - Use int32 for discussion number params (fixes CodeQL alerts) - Use strconv.ParseInt instead of Atoi for int32 targets - Fix IsStdoutTTY -> IsStderrTTY for web mode message - Use CancelError instead of error string for no-op edit - Trim whitespace from label names in resolution - Fix category error formatting (comma-joined instead of %q slice) - Fix typo in lookup.go comment - Remove dead len==0 check in view replies path - Inline exporterNeedsComments into needsComments - Validate comment ownership in GetCommentReplies - Remove unimplemented interface methods and CloseReason type Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
… command Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Return the discussion alongside the error when the primary mutation succeeds but a secondary mutation (e.g., labels) fails. Callers print the URL on stdout and the error on stderr, then exit with code 1. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rewrite the help text to be more conversational and less mechanical. Clarify that inline reply previews are not affected by --order. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…stResult Track the input pagination cursor on DiscussionListResult and add an ExportData method that conditionally includes cursor/next fields. Use ExportData in the list command instead of manually building the JSON envelope. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…sitoryMeta Move the HasDiscussionsEnabled check in GetByNumber, GetWithComments, and GetCommentReplies to a separate getRepositoryMeta call at the start. This ensures a clear "discussions disabled" error even when the main query fails for other reasons (e.g., discussion number not found). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…y mode Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add black-box acceptance tests for list, view, create, and edit commands. Tests cover disabled-discussions errors, basic CRUD, JSON output, label operations, pagination with cursor/next, comments, and replies. Also add jq-assert, jq, and jq2env testscript helper commands for asserting and extracting values from JSON environment variables. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Rewrite list command tests as a single table-driven TestListRun with exact output matching, inline exporter setup, and browser.Verify. Add TestListJSONFields and TestNewCmdList for field coverage and flag parsing. Add test cases for JSON cursor/next fields, all no-results states, and search path with cursor. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
The original TestNewCmdList was removed during test consolidation, so the temporary suffix is no longer needed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Stop wrapping ListCategories errors with "fetching categories:" in create and edit commands. The underlying error (e.g., "discussions disabled") is already descriptive and now surfaces consistently across all commands. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The field was set but never read; Client is the only HTTP path used. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Add client methods for managing discussion comments and replies: - AddComment: creates a top-level comment or reply via addDiscussionComment - UpdateComment: edits a comment body via updateDiscussionComment - DeleteComment: removes a comment via deleteDiscussionComment - GetComment: fetches a comment by node ID with typename validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement gh discussion comment for adding, editing, and deleting comments and replies on discussions. Supports --body, --body-file, --editor for input, --reply-to for threading, --edit and --delete for modifying existing comments, with confirmation prompts. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…PI calls Replace gh api graphql addDiscussionComment mutations in view and list acceptance tests with gh discussion comment. Extract comment IDs via a single view call with jq2env instead of multiple calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover add, reply, edit, delete flows including body-file input, non-interactive delete requiring --yes, and deletion of both parent comment and reply to avoid ghost entries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add test for --delete without --yes in non-TTY mode and fix existing delete tests to set isTTY: true for prompter-based confirmation. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add ParseDiscussionOrCommentArg to the shared package for parsing discussion numbers, URLs, comment node IDs, and comment URLs (with #discussioncomment-NNNNN fragments). Add ResolveCommentNodeID to the client for constructing node IDs from repository database ID and comment database ID via msgpack encoding. Update the comment command to accept comment URLs as positional args for reply, edit, and delete operations. Update the view command to accept comment URLs in the --replies flag. Add DiscussionID field to DiscussionComment for reply flow (fetches the parent discussion ID from a comment). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ests Update comment acceptance test to use positional comment IDs instead of --reply-to, and add URL-based add/edit/delete test cases. Update view acceptance test to cover --replies with a comment URL. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…ment argument Drop the --replies flag from gh discussion view and instead accept a comment URL or comment node ID (DC_*) as the positional argument. A discussion number, #number, or discussion URL behaves as before, while a comment reference shows that comment and its replies. Rework GetCommentReplies to be node-centric: it resolves the parent discussion directly from the comment node, so it no longer needs the discussion number or a repository ownership check. The method now takes a host string instead of a full repository. Also add a comment mode for --web that resolves and opens the comment URL, and add godoc to the DiscussionClient interface methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
GetComment resolves a comment by its node ID, so it only needs the host to select the GraphQL endpoint. Change its signature from a full ghrepo.Interface to a host string and update all callers and tests accordingly, mirroring GetCommentReplies. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…test Replace --replies usage with a positional comment node ID or URL to match the redesigned gh discussion view command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…gument In replies mode the --comments flag is meaningless, so reject the combination with a flag error instead of silently ignoring it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
feat(discussion): add comment command
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…s icon helper Collapse the three state-specific no-results messages into a single "no discussions found in <repo>" message, and render the answered column with the color scheme SuccessIcon helper for consistency with the view command. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Redesign the human-readable comment and reply output. Comments and replies are now displayed in chronological order regardless of the selected sort, reversing newest-first lists for display. Each header uses a bulleted layout with an abbreviated age, distinguishes between "commented" and "replied", and tags the newest comment or reply. Truncation notices now indicate whether older or newer items are hidden based on the fetch direction. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Make the non-interactive output of each mode print only what was asked for. Without --comments, only the discussion metadata and body are printed. With --comments, only the comments are printed, each as a metadata block (author, created, url, and answer when applicable) followed by its body. In replies mode, only the replies are printed in the same block format, without the parent comment. Comments and replies follow the same chronological ordering as the interactive output, and pagination cursors are no longer emitted in non-tty mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The discussion URL pattern captures one or more digits, which can exceed the int32 range. The parse error from strconv.ParseInt was previously discarded, silently clamping the number. Return an explicit error instead, and cover it with tests in both URL parsing functions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
…dit mode Signed-off-by: Babak K. Shandiz <babakks@github.com>
feat: add `discussion` command set
…README note (#13631) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Babak K. Shandiz <babakks@github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )