Skip to content

feat: add gh discussion create command#13359

Merged
babakks merged 8 commits into
cli:feature/discussionfrom
maxbeizer:discussion-create-cmd
May 7, 2026
Merged

feat: add gh discussion create command#13359
babakks merged 8 commits into
cli:feature/discussionfrom
maxbeizer:discussion-create-cmd

Conversation

@maxbeizer
Copy link
Copy Markdown
Contributor

Implements the gh discussion create CLI command, wiring up the Create client method from #13316.

Changes

  • New pkg/cmd/discussion/create/ package with create.go and create_test.go
  • Registers the command in discussion.go under the "General commands" group
  • Flags: --title/-t, --body/-b, --category/-c, --label/-l
  • Interactive prompting (TTY) when required flags are missing
  • Non-interactive mode requiring all flags

Part of stacked PRs

This is part of the gh discussion command series targeting feature/discussion.

Implements the 'gh discussion create' CLI command, wiring up the
already-merged Create client method. Supports:
- --title/-t, --body/-b, --category/-c, --label/-l flags
- Interactive prompting when TTY and required flags are missing
- Non-TTY mode requiring all flags
- TTY and non-TTY output formats

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@maxbeizer maxbeizer requested a review from a team as a code owner May 6, 2026 19:52
@maxbeizer maxbeizer requested review from babakks and removed request for a team May 6, 2026 19:52
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

Thanks for your pull request! Unfortunately, it doesn't meet the requirements for review:

  • None of the referenced issues have the help wanted label

Please update your PR to address the above. This PR will be automatically closed in 4 days if these requirements are not met.

Full contribution requirements
  1. Include a detailed description of what this PR does
  2. Link to an issue with the help wanted label (use Fixes #123 or Closes #123)

@github-actions github-actions Bot added external pull request originating outside of the CLI core team needs-triage needs to be reviewed labels May 6, 2026
@babakks babakks removed needs-triage needs to be reviewed unmet-requirements labels May 6, 2026
maxbeizer and others added 7 commits May 6, 2026 17:29
- Resolve labels before creating discussion so a bad label name
  doesn't leave an orphaned discussion (atomicity fix)
- Validate --title/--category/--body non-interactively before calling
  ListCategories to avoid an unnecessary network round-trip
- Set blankAllowed=false so the markdown editor rejects empty bodies
- Clarify help text: --body is required when not running interactively
- Update tests to match new behavior; rename label-not-found test to
  make the atomicity guarantee explicit

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Move non-interactive flag validation to arg parsing stage
- Add blank title/body/category validation at flag parsing
- Keep interactive blank-title/body checks after prompts
- Always print URL to stdout; success message to stderr in TTY mode
- Consolidate test cases and add isTTY field

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Babak K. Shandiz <babakks@github.com>
Only print the discussion URL to stdout. No additional output on stderr.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Merge TestCreateRun_nonInteractive, TestCreateRun_tty, and related tests
  into a single TestCreateRun table with 11 cases
- Add partial-flag cases for missing title, body, and category
- Add tty blank body returns error case
- Add tty does not prompt when all flags provided case

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>
@babakks
Copy link
Copy Markdown
Member

babakks commented May 7, 2026

Thanks for the PR, @maxbeizer! It's amazing! 🙏

I made some changes (expand below) and tested it end-to-end. I'll merge it once the CI is finished. Let me know if you have any comments so that I can fix in a follow up.

Next stop is implementing the API client methods for close and reopen both of which I think can be done in a single PR.

Changes

Details

Pushed a round of polish on top:

  • Validation: Moved non-interactive flag check to arg parsing (single error message instead of per-field). Added blank title/body/category validation at flag level.
  • Repo override: Added -R support so the command works with --repo OWNER/REPO.
  • Output: Only print the discussion URL to stdout (no success message on stderr). Keeps it pipe-friendly.
  • Spinners: Added progress indicators around ListCategories and Create API calls.
  • Tests: Consolidated all run tests into a single TestCreateRun table (11 cases covering non-tty, tty prompts, partial flags, blank input errors). Added wantBaseRepo assertion for -R override in TestNewCmdCreate.

Experience

Here are some screenshots for later reference.

Non-interactive

gh-discussion-create-non-interactive

Interactive (category selection)

gh-discussion-create-interactive-select-category

Interactive

gh-discussion-create-interactive

@babakks babakks merged commit 214885b into cli:feature/discussion May 7, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants