You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Global --json flag for machine-readable CLI output #199
There's no stable way for another program to read Flock's state. Only flock services has --json, so a menu bar, launcher or script integration has to scrape human-readable output that can change wording at any time.
The solution you'd like
Make --json a global (persistent) flag on the root command:
Commands with structured output return JSON:
status: daemon state, each service's state, the default PHP version, and whether Xdebug and dump capture are on
sites: each site's URL, path, PHP version and secure flag
php list: installed versions, with the default marked
isolated, mail, dumps and version
services --json keeps its current shape.
Commands that stream or wrap another process (daemon, logs, share, debug) exit with a clear error that --json isn't supported for them, rather than ignoring the flag.
The CLI is shared, so this works the same on macOS, Windows and Linux. The apps and the default text output stay as they are.
I'll send the PRs: the global flag plus status, sites and php list first, then the remaining commands.
Alternatives you've considered
Adding --json per command: this is how services does it today, but every new command would need to remember to add it.
Documenting the daemon's local HTTP API: that would make a larger surface public than the CLI.
The first PR is ready locally (global --json, plus status, sites and php list). A few questions before I open it, so the JSON shapes are settled before scripts start depending on them:
status --json shape. Right now it prints the daemon's api.Status as-is: 21 fields, including internals like processes, capture_off, event_count and dumps_in_page. That makes all of them a public contract, which is close to the "document the daemon API" option this issue argued against. Should status get its own small shape instead (daemon state, each service's state, default PHP, whether Xdebug and dump capture are on), the way sites does?
Site URLs with the daemon down. With the daemon running, sites --json URLs include non-default ports, as the daemon reports them. With it stopped, the fallback builds URLs from the config and leaves ports out (the text output already does this). The fields are the same either way, but the values change. Should the fallback include ports, or is that fine?
Commands that don't support JSON yet.daemon, logs, share and debug reject --json with a clear error. Every other command without JSON output (link, isolated, …) currently ignores the flag and prints text. Should they reject it too until they get JSON output, so a script never gets text it can't parse?
flock --json debug ….debug doesn't parse flags, so a leading --json shows up as its first argument. I treat that as the global flag and reject it, and flock debug --json … is rejected as well (PHP has no --json option). OK?
Proxies in sites --json. Each proxy has name, url and upstream, without a separate secure field, since the URL's scheme already says it. OK?
php is left out for Node.js sites. php list --json is [{"version": "8.5", "default": true}]. services --json and conflicts --json print exactly what they did before.
Activity
krlmrr commentedon Nov 25, 2026
The first PR is ready locally (global
--json, plusstatus,sitesandphp list). A few questions before I open it, so the JSON shapes are settled before scripts start depending on them:status --jsonshape. Right now it prints the daemon'sapi.Statusas-is: 21 fields, including internals likeprocesses,capture_off,event_countanddumps_in_page. That makes all of them a public contract, which is close to the "document the daemon API" option this issue argued against. Shouldstatusget its own small shape instead (daemon state, each service's state, default PHP, whether Xdebug and dump capture are on), the waysitesdoes?Site URLs with the daemon down. With the daemon running,
sites --jsonURLs include non-default ports, as the daemon reports them. With it stopped, the fallback builds URLs from the config and leaves ports out (the text output already does this). The fields are the same either way, but the values change. Should the fallback include ports, or is that fine?Commands that don't support JSON yet.
daemon,logs,shareanddebugreject--jsonwith a clear error. Every other command without JSON output (link,isolated, …) currently ignores the flag and prints text. Should they reject it too until they get JSON output, so a script never gets text it can't parse?flock --json debug ….debugdoesn't parse flags, so a leading--jsonshows up as its first argument. I treat that as the global flag and reject it, andflock debug --json …is rejected as well (PHP has no--jsonoption). OK?Proxies in
sites --json. Each proxy hasname,urlandupstream, without a separatesecurefield, since the URL's scheme already says it. OK?For reference,
sites --json:{ "sites": [ { "name": "quill", "url": "https://quill.test", "path": "/home/me/Sites/quill", "php": "8.5", "secure": true } ], "proxies": [] }phpis left out for Node.js sites.php list --jsonis[{"version": "8.5", "default": true}].services --jsonandconflicts --jsonprint exactly what they did before.