Skip to content

Add JSON output option for show command#637

Open
kasunch wants to merge 1 commit into
creativeprojects:masterfrom
kasunch:profile-json-output
Open

Add JSON output option for show command#637
kasunch wants to merge 1 commit into
creativeprojects:masterfrom
kasunch:profile-json-output

Conversation

@kasunch
Copy link
Copy Markdown

@kasunch kasunch commented May 12, 2026

Summary
The show command currently only outputs human-readable formatted text. Add a --json flag to output the effective configuration as structured JSON, making it easier to consume programmatically (e.g., in scripts, CI pipelines, or other tools).

Usage

resticprofile -n myprofile show --json
resticprofile myprofile.show --json

Expected output

  {
    "global": {
      "default-command": "snapshots",
      "initialize": "false",
      ...
    },
    "profile": {
      "repository": "/path/to/repo",
      "password-file": "key",
      ...
    },
    "schedules": [
      {
        "command": "backup",
        "at": ["daily"],
        ...
      }
    ]
  }
  • Output uses the same field names as the configuration file (from mapstructure tags).
  • Confidential values are masked, same as the text display.
  • Zero/empty values and internal fields are omitted, consistent with text output.
  • Nested maps and lists are preserved as proper JSON structures.
  • The top-level key is "profile" or "group" depending on the target.
  • "schedules" is only present when schedules are configured.

Add a --json flag to the show command that outputs the effective
configuration as structured JSON instead of formatted text.
@kasunch kasunch force-pushed the profile-json-output branch from a8c8230 to a6d2583 Compare May 12, 2026 20:32
@kasunch
Copy link
Copy Markdown
Author

kasunch commented May 12, 2026

Force-pushed to include a fix for nested maps and lists in the JSON output. Previously, nested structures (maps within maps, mixed-type lists) were flattened to strings like "key1:val1,key2:{a,b}". Now they are preserved as proper JSON objects and arrays.

No changes to the public API or command usage — just corrected the internal serialization in collectLeaf and collectSliceValue.

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