Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

docs(cli): say that -o and --json carry different shapes

EtienneLescot4237c00c412b
diff --git a/docs/cli.md b/docs/cli.md
index 4cc89dc79..44de0db79 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -106,7 +106,18 @@ Other launchers and log collectors do the same.
`-o <file>` writes the result somewhere no wrapper can redirect. It also avoids
shell quoting and encoding differences, which is worth more on Windows than on
-POSIX.
+POSIX. The file is written only on a successful run; a file left by an earlier
+run is not touched when a later one fails, so check the exit code rather than the
+file's presence.
+
+**The two channels carry different shapes.** `--json` on stdout wraps the payload
+in the NDJSON `done` envelope, because it is one event in a stream. `-o` writes
+the payload on its own, because a file is not a stream:
+
+```bash
+openscreen sources --json | jq '.sources.displays' # stdout: inside the envelope
+openscreen sources -o s.json && jq '.displays' s.json # file: the payload itself
+```
`--json` emits the payload on the final `done` event:
diff --git a/electron/cli/args.ts b/electron/cli/args.ts
index 4b0ef67cd..a3aee97c0 100644
--- a/electron/cli/args.ts
+++ b/electron/cli/args.ts
@@ -40,6 +40,11 @@ export type CliCommand = (
*
* A named file is a channel no wrapper can redirect into. It also sidesteps
* shell quoting and encoding, which matters more on Windows than on POSIX.
+ *
+ * Note the shapes differ, and docs/cli.md says so: stdout carries the payload
+ * inside the NDJSON `done` envelope because it is one event in a stream, while
+ * the file carries the bare payload because a file is not a stream. Written on
+ * success only.
*/
jsonOutPath?: string;
};