Skip to content

Add headless JSON CLI#58

Open
plyrthn wants to merge 1 commit into
Humblemonk:mainfrom
plyrthn:headless-cli
Open

Add headless JSON CLI#58
plyrthn wants to merge 1 commit into
Humblemonk:mainfrom
plyrthn:headless-cli

Conversation

@plyrthn

@plyrthn plyrthn commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

What this does

Adds non-interactive subcommands so shurectl can be scripted. Bare shurectl still launches the TUI; with a subcommand it prints JSON and exits.

Commands

  • shurectl get - full device state as JSON
  • shurectl set <setting> <value> - apply one setting, print the resulting state
  • shurectl set help - list every setting, its accepted values, and the models it applies to
  • shurectl preset list|save N|load N|delete N - host-side presets

Output is JSON on stdout. On error it prints {"error": ...} and exits non-zero, so callers can branch on the exit code.

shurectl set gain 24
shurectl set mute on
shurectl set hpf hz75
shurectl set compressor medium

Changes

  • headless.rs (new) - command dispatch, value parsing, settings catalog
  • main.rs - get/set/preset subcommands via clap; apply_preset_to_device refactored to take &ShureDevice so the TUI preset-load and preset load share it
  • Cargo.toml - add serde_json

Design

  • get reuses PresetSlot for its body, so the JSON field names and value tokens match the on-disk preset format
  • set parses enum values into the existing Ser* mirror types, so the tokens get emits are exactly the tokens set accepts, and an unknown value reports the valid variants
  • one catalog() is the source of truth for set help and the per-model applicability check, so a setting that does not apply to the connected model (e.g. phantom on an MV6) errors instead of silently no-opping
  • no protocol changes; it calls the same device.rs methods the TUI does

Tested

Against an MV6: get/set/preset round-trip, the help catalog, and the applicability and value-validation errors. Adds 10 unit tests for the parsers and catalog/dispatch consistency; fmt and clippy clean.

Adds non-interactive subcommands so shurectl can be scripted. Bare `shurectl`
still launches the TUI; with a subcommand it prints JSON and exits.

Commands:
- `shurectl get`: full device state as JSON
- `shurectl set <setting> <value>`: apply one setting, print the resulting state
- `shurectl set help`: list every setting, its accepted values, and the models
  it applies to
- `shurectl preset list|save N|load N|delete N`: host-side presets

Output is JSON on stdout. On error it prints {"error": ...} and exits non-zero,
so callers can branch on the exit code.

- `headless.rs` (new): command dispatch, value parsing, the settings catalog
- `main.rs`: clap subcommands; apply_preset_to_device now takes &ShureDevice so
  the TUI preset-load and `preset load` share it
- `Cargo.toml`: add serde_json

`get` reuses PresetSlot for its body, so the JSON field names and value tokens
match the on-disk preset format. `set` parses enum values into the existing
Ser* mirror types, so the tokens `get` emits are exactly the tokens `set`
accepts, and an unknown value reports the valid variants. One catalog() drives
`set help` and the per-model applicability check, so a setting that does not
apply to the connected model errors instead of silently no-opping. No protocol
changes; it calls the same device.rs methods the TUI does.
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