Skip to content

Read comment content from stdin when using dash#467

Merged
robzolkos merged 3 commits into
mainfrom
fix/comments-stdin-content
Jun 29, 2026
Merged

Read comment content from stdin when using dash#467
robzolkos merged 3 commits into
mainfrom
fix/comments-stdin-content

Conversation

@robzolkos

@robzolkos robzolkos commented May 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix comment creation and updates so using - reads the comment body from stdin instead of posting a literal dash. This supports heredoc/pipe workflows and prevents silent wrong-comment posts.

Relationship to #414

#414 is merged. This PR is now rebased onto main and complements #414: #414 covers implicit piped stdin when comment creation omits positional content; this PR covers the explicit - stdin convention and also applies it to comment updates.

Live verification

Tested against the Rob Zolkos account in the Verdant Coffee Roasters project,
Fusilli todolist, using a locally built branch with #414 and this PR.

  • printf ... | basecamp comment <todo_id> - created a comment with the piped content, not a literal -.
  • printf ... | basecamp comments update <comment_id> - updated the comment with the piped content.
  • printf ... | basecamp comments create <todo_id> still works for Add stdin support for comment content #414's implicit stdin path.
  • printf ... | basecamp comment <todo_id> - --edit fails fast with cannot combine --edit and positional content.
  • Empty stdin for basecamp comments update <comment_id> - fails with <content> required and does not send an API update.

Ref: https://3.basecamp.com/2914079/buckets/46292715/card_tables/cards/9890985489

Copilot AI review requested due to automatic review settings May 14, 2026 12:45
@github-actions github-actions Bot added commands CLI command implementations tests Tests (unit and e2e) labels May 14, 2026
@github-actions github-actions Bot added the bug Something isn't working label May 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for reading comment content from stdin when - is passed as the content argument to basecamp comment and basecamp comments update, enabling heredoc/pipe workflows and preventing accidental posts of a literal dash.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Changes:

  • Introduces helper contentArgOrStdin that reads from cmd.InOrStdin() when args is a single -.
  • Wires the helper into both the create (basecamp comment) and update (basecamp comments update) commands; updates help text with stdin examples.
  • Adds tests verifying stdin content is sent in the request body (not a literal dash) for both commands.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/commands/comment.go Adds contentArgOrStdin helper, uses it in create/update RunE, and extends help examples.
internal/commands/comment_test.go Adds mock transport + tests asserting stdin content is sent for create and update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/commands/comment.go">

<violation number="1" location="internal/commands/comment.go:327">
P2: `create` reads stdin for `-` before enforcing the `--edit` conflict, so `--edit` + `-` can hang waiting on stdin instead of failing fast.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread internal/commands/comment.go
@robzolkos

Copy link
Copy Markdown
Collaborator Author

Fixed — cubic found that --edit + - could read stdin before failing; the create command now rejects positional content with --edit before stdin handling.

@robzolkos robzolkos requested a review from jeremy May 14, 2026 13:13
Copilot AI review requested due to automatic review settings June 29, 2026 15:15
@robzolkos robzolkos force-pushed the fix/comments-stdin-content branch from 286fed0 to 56acd0c Compare June 29, 2026 15:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread internal/commands/comment.go
Comment thread internal/commands/helpers.go Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.

Re-trigger cubic

Comment thread internal/commands/comment_test.go
Copilot AI review requested due to automatic review settings June 29, 2026 15:35
@robzolkos robzolkos force-pushed the fix/comments-stdin-content branch from b16c738 to eb04433 Compare June 29, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread internal/commands/helpers.go Outdated
@robzolkos robzolkos force-pushed the fix/comments-stdin-content branch from eb04433 to 8eba978 Compare June 29, 2026 15:44
@robzolkos robzolkos force-pushed the fix/comments-stdin-content branch from 8eba978 to d44ad1d Compare June 29, 2026 16:03
@robzolkos robzolkos merged commit 5d3bc9c into main Jun 29, 2026
25 checks passed
@robzolkos robzolkos deleted the fix/comments-stdin-content branch June 29, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working commands CLI command implementations tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants