Skip to content

feat(cli): add generic output formatter to eliminate --output flag duplication#1753

Merged
johntmyers merged 3 commits into
NVIDIA:mainfrom
jeffmaury:GH-1750
Jun 8, 2026
Merged

feat(cli): add generic output formatter to eliminate --output flag duplication#1753
johntmyers merged 3 commits into
NVIDIA:mainfrom
jeffmaury:GH-1750

Conversation

@jeffmaury

Copy link
Copy Markdown
Contributor

Summary

Creates a new output.rs module with generic helper functions for formatting CLI command output in JSON, YAML, or table formats. This eliminates ~38 lines of duplicated code across 4 commands and provides a single source of truth for output formatting.

Related Issue

Closes #1750

Changes

  • New module: crates/openshell-cli/src/output.rs with 6 helper functions and 14 tests
    • print_output_collection() - For collections of items
    • print_output_single() - For single items
    • print_output_direct() - For pre-formatted output
  • Migrated commands in crates/openshell-cli/src/run.rs:
    • gateway_list(): 23 lines → 5 lines
    • sandbox_list(): 17 lines → 5 lines
    • provider_list_profiles(): 12 lines → 7 lines
    • provider_profile_export(): 11 lines → 8 lines
  • Documentation:
    • New architecture/cli.md - CLI architecture documentation
    • Updated architecture/README.md - Added CLI architecture reference

Testing

  • mise run pre-commit passes
  • Unit tests added/updated (14 new tests in output.rs)
  • E2E tests added/updated (not applicable - refactor preserves existing behavior)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@copy-pr-bot

copy-pr-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@jeffmaury

Copy link
Copy Markdown
Contributor Author

have read the DCO document and I hereby sign the DCO.

@jeffmaury

Copy link
Copy Markdown
Contributor Author

recheck

@jeffmaury jeffmaury force-pushed the GH-1750 branch 2 times, most recently from 9587486 to c96243a Compare June 4, 2026 17:25
@jeffmaury

Copy link
Copy Markdown
Contributor Author

recheck

…plication

Closes NVIDIA#1750

Creates a new output.rs module with generic helper functions for formatting
CLI command output in JSON, YAML, or table formats. This eliminates ~38 lines
of duplicated code across 4 commands, provides a single source of truth for
output formatting, and makes it easier to add new output formats in the future.

Changes:
- crates/openshell-cli/src/output.rs: New module with 6 helper functions and 14 tests
- crates/openshell-cli/src/lib.rs: Register output module
- crates/openshell-cli/src/run.rs: Migrate 4 commands to use helpers
  - gateway_list(): 23 lines → 5 lines
  - sandbox_list(): 17 lines → 5 lines
  - provider_list_profiles(): 12 lines → 7 lines
  - provider_profile_export(): 11 lines → 8 lines
- architecture/cli.md: New CLI architecture documentation
- architecture/README.md: Add reference to CLI architecture doc

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Jeff MAURY <jmaury@redhat.com>
@johntmyers johntmyers added the gator:watch-pipeline Gator is monitoring PR CI/CD status label Jun 4, 2026
@johntmyers

Copy link
Copy Markdown
Collaborator

gator-agent

PR Review Status

Validation: this PR is project-valid because it implements the linked validated CLI refactor from #1750 and keeps the work concentrated to CLI output helpers, four existing call sites, and architecture notes.
Head SHA: 6d3f53ffc619bce4e2dfa2cdd905fdfbacdb69c6

Review findings:

  • No blocking findings remain from the independent code-only review.

Docs: no Fern docs update is required because this preserves existing CLI behavior; architecture documentation was added under architecture/.

E2E: no test:* label required; this is an interface-preserving CLI refactor and does not affect sandbox lifecycle, gateway/supervisor behavior, policy enforcement, network proxy behavior, provider credential flow, runtime drivers, GPU, or Kubernetes behavior.

Next state: gator:watch-pipeline

@johntmyers

Copy link
Copy Markdown
Collaborator

/ok to test 6d3f53f

@johntmyers

Copy link
Copy Markdown
Collaborator

@jeffmaury thanks for the PR. we keep the arch directory intentionally thin. i think we can remove the cli.md addition and the reference to it. FYI gator to watch for this update.

@johntmyers johntmyers added gator:in-review Gator is reviewing or awaiting PR review feedback and removed gator:watch-pipeline Gator is monitoring PR CI/CD status labels Jun 4, 2026
@johntmyers

Copy link
Copy Markdown
Collaborator

gator-agent

Author Action Needed

Branch Checks are failing on the current head SHA 6d3f53ffc619bce4e2dfa2cdd905fdfbacdb69c6, and maintainer feedback has requested a doc-scope change.

Required author updates:

  • Remove architecture/cli.md and the architecture/README.md reference, per the maintainer comment above.
  • Fix Rust clippy failures in crates/openshell-cli/src/output.rs tests: replace assert_eq!(..., true) / assert_eq!(..., false) with assert!(...) / assert!(!...). Current failures are clippy::bool_assert_comparison at lines 332, 344, 356, 382, 394, 406, 416, 426, 450, 468, 485, and 500.

Markdown lint also reports architecture/cli.md:20 (MD032/blanks-around-lists), but removing the architecture doc addition should make that failure moot.

Next state: gator:in-review

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
@johntmyers

Copy link
Copy Markdown
Collaborator

gator-agent

Author Action Needed

Thanks for the follow-up update. The architecture doc feedback is resolved, and the prior bool-assert cleanup is mostly resolved, but the latest head SHA 991cc1825756e24d0c67687c784e7cbd72d65b03 still has one blocking test regression.

Required author update:

  • In crates/openshell-cli/src/output.rs, test_print_output_collection_table now uses assert!(result.unwrap()) even though print_output_collection("table", ...) intentionally returns Ok(false) so callers continue to table rendering. Please change it to assert!(!result.unwrap()).

I am keeping this in gator:in-review until that is fixed. After the next update, gator can re-check the diff and then move back to pipeline watch if no review findings remain.

@johntmyers

Copy link
Copy Markdown
Collaborator

/ok to test 991cc18

Signed-off-by: Jeff MAURY <jmaury@redhat.com>
@johntmyers

Copy link
Copy Markdown
Collaborator

gator-agent

Re-check After Author Update

I re-evaluated latest head 82505eab2db5a83b9db5f66c1d993060bf6a93ed after jeffmaury's 2026-06-08 commit, fix: fix wrong CLI output test.

Disposition: resolved. The prior test_print_output_collection_table regression is fixed with assert!(!result.unwrap()), matching the intended Ok(false) table behavior.

Remaining items:

  • No blocking review items remain from the independent code-only re-review.

Docs: no Fern docs update is required because this preserves existing CLI behavior; the architecture doc addition and README reference were removed per maintainer feedback.

E2E: no test:* label required for this interface-preserving CLI refactor.

Next state: gator:watch-pipeline

@johntmyers johntmyers added gator:watch-pipeline Gator is monitoring PR CI/CD status and removed gator:in-review Gator is reviewing or awaiting PR review feedback labels Jun 8, 2026
@johntmyers

Copy link
Copy Markdown
Collaborator

/ok to test 82505ea

@johntmyers johntmyers removed the gator:watch-pipeline Gator is monitoring PR CI/CD status label Jun 8, 2026
@johntmyers johntmyers added the gator:approval-needed Gator completed review; maintainer approval needed label Jun 8, 2026
@johntmyers

Copy link
Copy Markdown
Collaborator

gator-agent

Maintainer Approval Needed

Gator validation and PR monitoring are complete.

Validation: this PR is project-valid because it implements the linked validated CLI refactor from #1750 and keeps the final change concentrated to CLI output helper reuse in crates/openshell-cli.
Review: no blocking findings remain from the independent code-only review and follow-up re-check at head 82505eab2db5a83b9db5f66c1d993060bf6a93ed.
Docs: no Fern docs update is required because this preserves existing CLI behavior; the architecture doc addition and README reference were removed per maintainer feedback.
Checks: required gates are green: OpenShell / Branch Checks, OpenShell / Helm Lint, and DCO.
E2E: N/A; no test:* labels are required for this interface-preserving CLI refactor, and OpenShell / E2E plus OpenShell / GPU E2E report pass because those labels are not applied.

Human maintainer approval or merge decision is now required.

@johntmyers johntmyers merged commit 4da07f6 into NVIDIA:main Jun 8, 2026
31 of 33 checks passed
@jeffmaury jeffmaury deleted the GH-1750 branch June 8, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:approval-needed Gator completed review; maintainer approval needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(cli): generic output formatter to eliminate --output flag duplication

2 participants