<#9570 feat: Make `meltano state get` output compa...
# meltano-repo-activity
g
#9570 feat: Make `meltano state get` output compatible with `meltano state set` Pull request opened by tayloramurphy ## Summary Fixes #6775 This PR modifies
meltano state get
to output compact JSON by default, making it directly compatible with
meltano state set
without manual formatting adjustments. ## Changes • Added
--format
option to
meltano state get
with two modes: •
json
(default): Compact single-line output ready for
meltano state set
• `pretty`: Human-readable indented output (legacy behavior) • Default output uses compact JSON serialization with no spaces after separators • Comprehensive test coverage for both format modes and round-trip compatibility ## Breaking Change (v4) The default output format has changed from pretty-printed JSON to compact JSON. Users who need indented output can use
--format pretty
or pipe the output through
jq
. Before: { "singer_state": { "bookmarks": {...} } } After (default): {"singer_state":{"bookmarks":{...}}} ## Usage Examples # Get state in compact format (default) - ready for state set meltano state get dev:tap-gitlab-to-target-jsonl # Get state in human-readable format meltano state get dev:tap-gitlab-to-target-jsonl --format pretty # Copy state between jobs (now works seamlessly) STATE=$(meltano state get dev:tap-gitlab-to-target-jsonl) meltano state set --force prod:tap-gitlab-to-target-jsonl "$STATE" ## Testing • All 40 existing state CLI tests pass • Added 4 new tests: • `test_get_default_format_is_compact`: Verifies default output is compact • `test_get_format_json_option`: Tests explicit
--format json
flag • `test_get_format_pretty_option`: Tests
--format pretty
flag • `test_get_set_roundtrip`: Critical test - verifies output from
get
works directly in
set
## Migration Guide Users relying on pretty-printed output from
meltano state get
should: • Use
--format pretty
flag for human-readable output • Pipe output through
jq
for custom formatting • Update any scripts that parse the output format ## Summary by Sourcery Make state get output compact by default and introduce a format flag to toggle between compact and pretty JSON, ensuring seamless compatibility with state set New Features: • Add --format option to meltano state get with 'json' and 'pretty' modes Enhancements: • Change default state get output to compact JSON for direct compatibility with state set Tests: • Add tests verifying default compact output, explicit json and pretty formats, and state get-set roundtrip meltano/meltano