Skip to content

feat: add --sort flag to yaml, json, and between subcommands - #671

Open
shikanime wants to merge 4 commits into
homeport:mainfrom
shikanime:feat/yaml-sort-flag
Open

feat: add --sort flag to yaml, json, and between subcommands#671
shikanime wants to merge 4 commits into
homeport:mainfrom
shikanime:feat/yaml-sort-flag

Conversation

@shikanime

@shikanime shikanime commented Jun 15, 2026

Copy link
Copy Markdown

Summary

Adds a --sort flag to yaml and between subcommands to sort YAML map keys alphabetically, eliminating false order-change diffs when keys differ only in insertion order.

Changes

between command

  • New flag: --sort
  • Sorts both from and to document trees before comparison using sortYAMLKeys()

yaml converter

  • New flag: --sort / -s
  • Sorts mapping keys alphabetically in YAML output

Shared utilities

  • common.go: sortYAMLKeys() recursive helper, OutputWriter.SortKeys field

Note: json subcommand intentionally excluded — encoding/json already sorts map keys alphabetically, so the flag would be a no-op.

Tests

  • All 45 tests pass (2 new test cases for yaml and between)

@shikanime shikanime changed the title feat(yaml): add --sort flag for alphabetical key sorting feat: add --sort flag to yaml, json, and between subcommands Jun 15, 2026
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.

1 participant