Skip to content

feat(cli): add JSON output for list and status - #77

Open
iloveitaly wants to merge 4 commits into
peterldowns:mainfrom
iloveitaly:cli-json-output
Open

iloveitaly wants to merge 4 commits into
peterldowns:mainfrom
iloveitaly:cli-json-output

Conversation

@iloveitaly

@iloveitaly iloveitaly commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Obviously, this was built with AI. I've been using it locally for a couple weeks locally and it works great.

Motivation

Projects using Localias need to check daemon state and saved alias ports during test preflight without parsing human-readable output.

Here's an example of where this is useful.

Description

Add localias status --json and localias list --json with typed output:

{"running":true,"pid":98213}
{"aliases":{"api-test.movie-tickets.localhost":14201,"embed.movie-tickets.localhost":14204}}

A stopped daemon returns {"running":false,"pid":null} successfully. Empty aliases return {"aliases":{}}. Each successful JSON command writes one document to stdout; errors exit nonzero with plain diagnostics on stderr. list --format json is equivalent to --json, and text remains the default output.

Preserve PID-file and process-permission errors instead of reporting them as stopped. Reject invalid or conflicting output flags and propagate output write errors.

The README and command help explicitly distinguish saved configuration from active daemon configuration. list reads the selected saved file; a live configuration query remains future work, so these commands alone cannot detect stale ports still running in the daemon.

Test

  • Passed go test ./... and golangci-lint 2.15.0.
  • CLI subprocess tests cover JSON types and single-document output, empty results, selected saved configurations, text output, flag errors, plain diagnostics with color enabled, and running/stopped/stale/invalid PID states.
  • Unit tests cover JSON alias escaping and output write failures.

Links

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