spotify-cli / output
output
JSON output helpers for the CLI.
All CLI output is JSON — successful results go to stdout, errors go to stderr. This keeps output machine-parseable.
Functions
handleError()
handleError(
err):never
Defined in: src/output.ts:39
Top-level error handler that logs a JSON error and exits the process.
If the error is a SpotifyCliError, its exit code and details are used. Otherwise the process exits with ExitCode.API.
Parameters
err
unknown
The caught error value.
Returns
never
logError()
logError(
message,details?):void
Defined in: src/output.ts:25
Writes a JSON error object to stderr.
Parameters
message
string
Error message string.
details?
Record<string, unknown>
Optional additional context included in the JSON output.
Returns
void
output()
output(
data):void
Defined in: src/output.ts:16
Writes a JSON-serialized value to stdout.
Parameters
data
unknown
Any value to serialize and print.
Returns
void