Add discussion view command#13093
Closed
maxbeizer wants to merge 2 commits into
Closed
Conversation
Contributor
Author
Implement `gh discussion view` for viewing a single discussion with: - Number or URL argument via shared.ParseDiscussionArg - TTY output: title, metadata (state, category, author, age, comment count), labels, markdown-rendered body, reactions - Context-aware author attribution: "Asked by" for answerable categories (Q&A), "Started by" for others - Non-TTY output: key-value pairs matching `gh issue view` format - JSON output via Exporter (Discussion.ExportData) - --web flag to open in browser - Pager support for TTY output Also adds: - GetByNumber client method with not-found detection - shared.ParseDiscussionArg for number/URL/#number parsing - shared.ReactionGroupList for emoji reaction display Comment threading (--comments) is deferred to the next PR. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
73b04cb to
f3c9821
Compare
- 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>
Member
|
Closing this as already completed in #13214 |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements
gh discussion view— view a single discussion with full metadata, body, and reactions (PR 3 of 11).Features
123),#123, or full URL (https://github.com/OWNER/REPO/discussions/123)gh issue viewformatExportDatasupport with--json,--jq,--template--webopens discussion in browserFlags
Implementation
GetByNumberonDiscussionClient— plain text GraphQL, reusesdiscussionNode/mapDiscussionfrom list, with null-pointer detection for not-foundshared.ParseDiscussionArg— number/URL/#number parsershared.ReactionGroupList— emoji reaction formatter for domain typesTests
8 test cases: TTY, non-TTY, JSON, web mode, URL argument, answerable vs non-answerable categories, arg parsing. All use
DiscussionClientMock.What's next
PR 4:
discussion view --comments(threading)Ref: #12810