Skip to content

feat: add --output markdown format#678

Merged
nieblara merged 18 commits intomainfrom
feat/markdown-output
Apr 15, 2026
Merged

feat: add --output markdown format#678
nieblara merged 18 commits intomainfrom
feat/markdown-output

Conversation

@nieblara
Copy link
Copy Markdown
Contributor

@nieblara nieblara commented Apr 14, 2026

Summary

  • Registers markdown as a valid --output kind alongside json and plaintext
  • Adds markdown rendering for resource output: GFM tables for lists, key-value bullets for singular resources, and a rich flag view with environment status table
  • Extracts paginationSuffix helper to share between plaintext and markdown paths

Stacked on feat/dry-run-flag

Test plan

  • All existing internal/output tests pass
  • New unit tests for markdown rendering helpers (markdown_test.go)
  • Integration tests through CmdOutput for singular, list, pagination, empty, and unknown resource cases (resource_output_test.go)
  • Command-level tests for archive, toggle-on, toggle-off with --output markdown

Made with Cursor


Note

Medium Risk
Adds a new output mode that changes user-visible formatting paths across many commands; risk is mainly in rendering/edge cases (pagination, empty lists) rather than data or auth logic.

Overview
Adds markdown as a supported --output kind (alongside json/plaintext) and updates CLI/config help + validation error messages accordingly.

Implements GitHub-flavored markdown rendering for resource output: tables for lists, bullet key/value blocks for singular resources, and a richer flag view with an environments status table and extra metadata. Refactors pagination formatting into a shared paginationSuffix helper and extends command/unit tests to cover markdown output and edge cases (empty results, unknown resources, pagination, --fields ignored outside JSON).

Reviewed by Cursor Bugbot for commit 36e0576. Bugbot is set up for automated code reviews on this repo. Configure here.

nieblara added 15 commits March 17, 2026 20:02
* [feat] Agent friendly error handling

* feat(REL-12755): adding --fields flag (#662)

* [feat] adding --fields flag

* feat(REL-15756): updating agent friendly and improved rich text output (#663)

feat(REL-15756) updating agent friendly and improved rich text output
Three tests in root_test.go still asserted the old `name (key)` bullet
format, but the toggle-on command now passes ResourceName: "flags" which
triggers key-value output. Update to match the actual output shape.

Made-with: Cursor
Remove the standalone `fields []string` positional parameter from
CmdOutput and pass fields exclusively through CmdOutputOpts.Fields.
This eliminates the dual-path API and simplifies every call site.

Also emit a stderr warning when --fields is used with plaintext output,
since the flag is silently ignored in that mode.

Made-with: Cursor
…ELOG

Add entries for the error JSON shape change (new statusCode/suggestion
fields, message casing) and the plaintext table format change. Both are
breaking changes that should be called out for v3.0.

Made-with: Cursor
The API already supports dryRun as a query parameter on PATCH
/api/v2/flags. The auto-generated `flags update` command exposes it,
but the hand-rolled toggle and archive commands passed nil for query
params. This wires --dry-run through to MakeRequest on all three.

Also adds a Query field to MockClient so tests can verify query params.

Made-with: Cursor
Copy-paste error had both dry-run subtests invoking toggle-on instead
of toggle-off, so toggle-off's --dry-run path was never exercised.

Made-with: Cursor
Add "markdown" alongside "json" and "plaintext" as accepted values for
the --output flag. Update validation, help text, and related tests.

Made-with: Cursor
Implement markdown formatting for singular and list responses:
- Flags get a rich view with environment status table and metadata
- Known resources use GFM tables for lists, key-value bullets for detail
- Unknown resources fall back to headings / bullet lists
- Extract paginationSuffix helper to share between plaintext and markdown

Made-with: Cursor
Cover --output markdown through archive, toggle-on, and toggle-off
command tests to verify end-to-end markdown rendering.

Made-with: Cursor
Comment thread internal/output/markdown.go
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 454b585. Configure here.

Comment thread internal/output/output.go
Base automatically changed from feat/dry-run-flag to main April 14, 2026 20:01
@nieblara nieblara requested a review from a team April 14, 2026 20:02
@nieblara
Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Co-authored-by: nieblara <17378597+nieblara@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@ari-launchdarkly ari-launchdarkly left a comment

Choose a reason for hiding this comment

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

Did we add markdown as an output? We should test that too if we can. It looks like it was added to the description but I'm not sure if that's just a change to align it to reality

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

@copilot resolve the merge conflicts in this pull request

Resolved in 36e0576. The conflicts were in cmd/flags/archive_test.go and cmd/flags/toggle_test.go — both files had the markdown output tests from this PR colliding with the dry-run tests that were added to main when the stacked PR was squash-merged. The resolution keeps both sets of tests.

@nieblara
Copy link
Copy Markdown
Contributor Author

Did we add markdown as an output? We should test that too if we can. It looks like it was added to the description but I'm not sure if that's just a change to align it to reality

ah @ari-launchdarkly seems like we had a few conflicts that i needed to resolve before the updated diff showed up for you - so i think its good for you to check out again! the changes here should include the markdown output

@ari-launchdarkly
Copy link
Copy Markdown
Contributor

@copilot would you mind reviewing this PR?

Copy link
Copy Markdown
Contributor

@ari-launchdarkly ari-launchdarkly left a comment

Choose a reason for hiding this comment

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

Great work!

Comment on lines +18 to +23
var sb strings.Builder
sb.WriteString("| ")
sb.WriteString(strings.Join(headers, " | "))
sb.WriteString(" |\n| ")
sb.WriteString(strings.Join(separators, " | "))
sb.WriteString(" |")
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.

is there any value to us having a utility to build this out? Just curious, not asking for a change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

right now, just dont see the need for a dependency for something im not sure will change often yet - but ill keep an eye out for something suitable!

for _, item := range items {
vals := make([]string, len(cols))
for i, col := range cols {
vals[i] = escapeMDPipe(colValue(item, col))
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.

do we need error handling here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

a good idea - deferring to a future pr

@nieblara nieblara merged commit 9872c28 into main Apr 15, 2026
5 checks passed
@nieblara nieblara deleted the feat/markdown-output branch April 15, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants