Skip to content

mutagen sync list: add structured output format (e.g. --output json) #565

Description

@ksemele

Third-party tools and IDE integrations currently have to parse the human-readable text output of mutagen sync list. This is fragile and expensive to maintain. A structured output flag (analogous to kubectl get ... -o json or docker inspect) would make it straightforward to build reliable integrations.

Motivation

I'm building a VS Code extension source code that polls mutagen sync list on a configurable interval to display session state in a tree view and status bar. The current parser has to:

  • Split the output on ---...--- separator lines
  • Track indentation level to distinguish root fields from Alpha: / Beta: / Conflicts: sub-sections
  • Pattern-match the Status: string against a hardcoded list of substrings ("staging", "reconciling", "scanning", "applying", "saving", "waiting") to classify the session as syncing
  • Parse Connected: Yes/No as a boolean

Any change to the output format — new fields, reworded status strings, indentation changes — silently breaks the parser.
The categorizeStatus() function in particular is a maintenance liability: it has to be updated every time a new status phase is introduced.

Proposed solution

Add a --output (or --format) flag to mutagen sync list:

mutagen sync list --output json
mutagen sync list --output json <session-name>

The JSON output should include the same information currently shown in the text output:

[
  {
    "name": "my-session",
    "identifier": "...",
    "status": "watching",           // machine-readable enum
    "statusDescription": "Watching for changes",  // human-readable, as today
    "paused": false,
    "alpha": {
      "url": "...",
      "connected": true
    },
    "beta": {
      "url": "user@host:/path",
      "connected": true
    },
    "lastError": null,
    "conflicts": []
  }
]

Key asks:

  • status as a stable machine-readable enum (not a display string) — this is the most important part. Right now statusDescription changes phrasing between versions; a separate enum field would be stable across releases.
  • connected as a proper boolean, not "Yes"/"No" string
  • Empty array for conflicts when none (not omitting the field)
  • Exit code 0 with [] when no sessions exist (currently outputs "No sessions found." to stdout)

Prior art

kubectl get pods -o json
docker inspect <container>
gh pr list --json number,title,state
terraform show -json

All of these kept their human-readable default output and added --output json as an opt-in. Same approach would work here with no breaking changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions