Skip to content

Adopt shared output package and add format flags - #75

Merged
jeremy merged 10 commits into
masterfrom
parity
Mar 5, 2026
Merged

Adopt shared output package and add format flags#75
jeremy merged 10 commits into
masterfrom
parity

Conversation

@jeremy

@jeremy jeremy commented Mar 5, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace internal/response with basecamp/cli/output package for standardized CLI envelope (ok/error), structured error types, and format-aware output
  • Add --json, --quiet, --ids-only, --count global format flags (mutually exclusive, default JSON)
  • Remove dead --pretty flag
  • Fix all 17 pre-existing golangci-lint issues (errcheck + nilerr)
  • Set default make target to check (CI gate)

Commits

  1. Adopt shared output package — errors shim, output.Writer, all commands + tests, response package deletion (46 files)
  2. Update e2e harness and tests — envelope field renames (17 files)
  3. Update docs — SKILL.md + README envelope format
  4. Add format flags--json/--quiet/--ids-only/--count with PersistentPreRunE resolution, unit + Cobra integration tests
  5. Fix lint issues — errcheck + nilerr directives
  6. Default make targethelpcheck

Format flags

Flag Output
--json JSON envelope with ok, data, breadcrumbs, context (default)
--quiet Raw JSON data, no envelope
--ids-only One ID per line
--count Integer count of results

Conflicting flags produce a usage error. Format resolution happens in PersistentPreRunE after Cobra parses flags.

Test plan

  • make (check) passes — 0 lint issues, all unit tests green
  • go run ./cmd/fizzy version --count1
  • go run ./cmd/fizzy version --quiet → raw JSON, no envelope
  • go run ./cmd/fizzy version --quiet --count → usage error, exit 1
  • make test-e2e (needs credentials)

Copilot AI review requested due to automatic review settings March 5, 2026 02:44
@github-actions github-actions Bot added the enhancement New feature or request label Mar 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c4c97d978

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/commands/root.go

Copilot AI 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.

Pull request overview

This PR migrates the Fizzy CLI from the local internal/response envelope to the shared github.com/basecamp/cli/output package, adds mutually-exclusive global output format flags, and updates unit/E2E tests + docs to match the new envelope (ok/error + context).

Changes:

  • Replace internal/response with output.Writer + shared output.Response/output.Error types and conventions.
  • Add global output format flags (--json, --quiet, --ids-only, --count) resolved in PersistentPreRunE.
  • Update docs/tests and align exit-code mappings to the shared rubric; change default make target to check.

Reviewed changes

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

Show a summary per file
File Description
skills/fizzy/SKILL.md Update flags + envelope docs
internal/response/response.go Remove legacy response package
internal/errors/errors.go Re-export shared output errors/codes
internal/errors/errors_test.go Update exit-code/error-code tests
internal/commands/root.go Add format flags + output.Writer shims
internal/commands/format_test.go Add format flag tests
internal/commands/version.go Convert to RunE + return errors
internal/commands/board.go Migrate to RunE + output helpers
internal/commands/board_test.go Update tests for RunE/output
internal/commands/column.go Migrate to RunE + output helpers
internal/commands/column_test.go Update tests for RunE/output
internal/commands/comment.go Migrate to RunE + output helpers
internal/commands/comment_test.go Update tests for RunE/output
internal/commands/comment_attachment.go Migrate to RunE + output helpers
internal/commands/comment_attachment_test.go Update tests for RunE/output
internal/commands/reaction.go Migrate to RunE + output helpers
internal/commands/reaction_test.go Update tests for RunE/output
internal/commands/pin.go Migrate to RunE + output helpers
internal/commands/pin_test.go Update tests for RunE/output
internal/commands/notification.go Migrate to RunE + output helpers
internal/commands/notification_test.go Update tests for RunE/output
internal/commands/user.go Migrate to RunE + output helpers
internal/commands/user_test.go Update tests for RunE/output
internal/commands/upload.go Migrate to RunE + output helpers
internal/commands/upload_test.go Update tests for RunE/output
internal/commands/tag.go Migrate to RunE + output helpers
internal/commands/tag_test.go Update tests for RunE/output
internal/commands/step.go Migrate to RunE + output helpers
internal/commands/step_test.go Update tests for RunE/output
internal/commands/search.go Migrate to RunE + output helpers
internal/commands/search_test.go Update tests for RunE/output
internal/commands/identity.go Migrate to RunE + output helpers
internal/commands/identity_test.go Update tests for RunE/output
internal/commands/migrate.go Migrate to RunE + output helpers
internal/commands/migrate_test.go Update tests for RunE/output
internal/commands/auth.go Migrate to RunE + output helpers
internal/commands/auth_test.go Update tests for RunE/output
internal/commands/attachment.go Migrate to RunE + output helpers
internal/commands/attachment_test.go Update tests for RunE/output
internal/commands/setup.go Convert setup wizard to RunE
internal/commands/skill.go Convert skill installer to RunE
internal/commands/mock_client_test.go Add assertExitCode helper
internal/client/client_test.go Update error expectations/methods
e2e/harness/harness.go Update harness envelope + exit codes
e2e/tests/auth_test.go Update to ok/error envelope
e2e/tests/board_test.go Update to ok/context pagination
e2e/tests/card_test.go Update to ok/error envelope
e2e/tests/column_test.go Update to ok/error envelope
e2e/tests/comment_test.go Update to ok/error envelope
e2e/tests/comment_attachment_test.go Update to ok/error envelope
e2e/tests/error_test.go Update error envelope assertions
e2e/tests/identity_test.go Update error shape (code/error string)
e2e/tests/notification_test.go Update to ok/error envelope
e2e/tests/pin_test.go Update to ok/error envelope
e2e/tests/reaction_test.go Update to ok/error envelope
e2e/tests/step_test.go Update to ok/error envelope
e2e/tests/tag_test.go Update to ok/error envelope
e2e/tests/upload_test.go Update to ok/error envelope
e2e/tests/user_test.go Update to ok/error envelope
README.md Update JSON envelope example
Makefile Default target -> check
go.mod Add github.com/basecamp/cli dep
go.sum Update module checksums

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

Comment thread internal/commands/root.go
Comment thread internal/commands/format_test.go
jeremy added 6 commits March 4, 2026 18:52
Replace the internal response package with basecamp/cli/output, which
provides a standard CLI envelope (ok/error), structured error types,
and an output.Writer for format-aware rendering.

- Rewrite internal/errors as thin type aliases over output.Error
- Wire output.Writer into root command Execute() and test harness
- Update all command files to use Breadcrumb alias from root.go
- Update all unit tests for .Response.OK (was .Response.Success),
  method-based .ExitCode(), and Context-based location/pagination
- Delete internal/response/ (superseded by output package)
Rewrite the e2e harness Response struct to match the output package
envelope (OK/Error fields, Context for location/pagination). Update
all 16 e2e test files for the new field names and assertion helpers.
Reflect the new response envelope field names (ok/error instead of
success/failure) in the SKILL.md agent documentation and README.
Replace the dead --pretty flag with four output format flags that
thread through the shared output package:

  --json      JSON envelope (default, explicit)
  --quiet     Raw JSON data without envelope
  --ids-only  One ID per line
  --count     Integer count of results

Format resolution happens in PersistentPreRunE after Cobra parses
flags. At most one format flag may be set; conflicts produce a
usage error. Default remains FormatJSON — FormatAuto deferred until
the output package has renderer support.
- Check return values from out.OK(), out.Err(), json.Unmarshal (errcheck)
- Add nolint:nilerr directives for intentional nil returns on user
  cancellation in setup and skill interactive prompts
make with no arguments now runs the full CI gate (fmt-check + vet +
lint + test-unit + tidy-check) instead of printing help.
- Wrap plain errors in auth, skill, and completion commands as
  output.Error{Code: CodeAPI} so they aren't misclassified as usage
  errors by the Execute() catch-all.
- Only set lastResult.Response on successful JSON unmarshal in
  captureResponse, avoiding zero-value responses for non-JSON formats.
- Reset format flag variables in runCobraWithArgs to prevent state
  leaking between integration test calls.
Copilot AI review requested due to automatic review settings March 5, 2026 02:58

Copilot AI 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.

Pull request overview

Copilot reviewed 67 out of 68 changed files in this pull request and generated 3 comments.


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

Comment thread internal/commands/root.go
Comment thread internal/commands/root.go
Comment thread internal/errors/errors.go
jeremy added 2 commits March 4, 2026 19:38
- Clear lastResult.Response before unmarshal attempt in captureResponse
  to prevent stale responses leaking across non-JSON format test runs.
- Use any instead of interface{} in printSuccess helper signatures and
  pagination context map for consistency with repo conventions.
- Preserve server-provided message on 429 rate limit errors in
  FromHTTPStatus instead of dropping it.
Copilot AI review requested due to automatic review settings March 5, 2026 03:41

Copilot AI 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.

Pull request overview

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


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

Comment thread internal/commands/attachment_test.go
Data comes back as []any from JSON unmarshal, not []Attachment.
The previous assertion silently failed, skipping the count check.
@jeremy
jeremy merged commit 53db558 into master Mar 5, 2026
14 checks passed
@jeremy
jeremy deleted the parity branch March 5, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants