Skip to content

fix(json): rename --schema to --keys-only, closes #621#890

Open
FlorianBruniaux wants to merge 2 commits intodevelopfrom
fix/filter-truncation-621
Open

fix(json): rename --schema to --keys-only, closes #621#890
FlorianBruniaux wants to merge 2 commits intodevelopfrom
fix/filter-truncation-621

Conversation

@FlorianBruniaux
Copy link
Copy Markdown
Collaborator

Summary

  • Renames rtk json --schema to rtk json --keys-only
  • Values are preserved by default (already the behavior) — this makes the opt-in explicit
  • Internal schema_only parameter name is unchanged (private API)

Context

Closes #621. The three signal truncation problems in that issue:

  1. git diff max hunk lines — already raised to 100 on develop (prior commits)
  2. git log body lines — already at 3 non-empty lines on develop (prior commits)
  3. json values default — already preserved in filter_json_compact() (prior commits), but the opt-in flag was named --schema instead of --keys-only

This PR addresses item 3: the flag name. --keys-only is clearer than --schema because it names what the flag does (shows only keys) rather than what mode it enables.

Before / After

# Before
rtk json config.json --schema  # keys only

# After
rtk json config.json --keys-only  # keys only (same behavior, better name)
rtk json config.json               # values preserved (unchanged default)

Test plan

  • 1123 tests pass (cargo test --all)
  • cargo clippy --all-targets — 0 warnings
  • rtk json --help shows --keys-only flag

🤖 Generated with Claude Code

FlorianBruniaux and others added 2 commits March 28, 2026 01:22
The previous --schema flag name implied output type rather than behavior.
--keys-only is explicit: values are shown by default, this flag strips them.

Closes #621 (json values now preserved by default; --keys-only is opt-in).

Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
Adds a one-liner listing all supported ecosystems (ruff, pytest, pip,
golangci-lint, etc.) in the Architecture section to satisfy the pre-push
documentation validation script.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Florian BRUNIAUX <florian@bruniaux.com>
Copilot AI review requested due to automatic review settings March 28, 2026 00:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Renames the rtk json CLI flag from --schema to --keys-only to better reflect that the mode shows JSON structure/keys only, while keeping values in the default output.

Changes:

  • Renamed rtk json --schema to rtk json --keys-only in Clap CLI wiring.
  • Updated inline CLI/help documentation strings describing rtk json behavior.
  • Added a short “Supported ecosystems” note to CLAUDE.md.

Reviewed changes

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

File Description
src/main.rs Renames the json subcommand flag field from schema to keys_only and forwards it into json_cmd.
src/cmds/system/json_cmd.rs Updates run() doc comment to reference --keys-only.
CLAUDE.md Documents supported ecosystems for contributors/agents.

depth: usize,
/// Show structure only (strip all values)
/// Show keys only (strip all values, show structure)
#[arg(long)]
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

Renaming the user-facing flag from --schema to --keys-only is a breaking CLI change (existing scripts/aliases will stop working). Consider adding a clap alias for backwards compatibility (and optionally deprecating it in help output) so both flags work for a transition period.

Suggested change
#[arg(long)]
#[arg(long, alias = "schema")]

Copilot uses AI. Check for mistakes.
Comment on lines +198 to +207
/// Show JSON (compact values by default, or keys-only with --keys-only)
Json {
/// JSON file
file: PathBuf,
/// Max depth
#[arg(short, long, default_value = "5")]
depth: usize,
/// Show structure only (strip all values)
/// Show keys only (strip all values, show structure)
#[arg(long)]
schema: bool,
keys_only: bool,
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

This PR changes CLI parsing for rtk json (new --keys-only flag), but src/main.rs has clap parsing unit tests and none cover this flag. Add tests asserting rtk json <file> --keys-only parses (and, if you keep it, that the legacy --schema alias parses too / or errors as intended).

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +38 to 40
/// Show JSON (compact with values by default, or keys-only with --keys-only)
pub fn run(file: &Path, max_depth: usize, schema_only: bool, verbose: u8) -> Result<()> {
validate_json_extension(file)?;
Copy link

Copilot AI Mar 28, 2026

Choose a reason for hiding this comment

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

The module-level doc comment at the top of this file still states JSON is inspected "without showing values", but the current behavior/docs indicate values are shown by default (keys-only is opt-in). Update the module docs (and any referenced docs that still claim values are stripped by default) to avoid misleading users/contributors.

Copilot uses AI. Check for mistakes.
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.

2 participants