diff --git a/doc/cli.markdown b/doc/cli.markdown index 8ace6915..395c324a 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -2655,6 +2655,10 @@ device type (Check available types with `balena devices supported`) path to OS image file (e.g. balena.img) or block device (e.g. /dev/disk2) +#### -j, --json + +produce JSON output instead of tabular output + ## config reconfigure Interactively reconfigure a provisioned device or OS image. diff --git a/lib/commands/config/read.ts b/lib/commands/config/read.ts index 79cf0670..99d3b3f6 100644 --- a/lib/commands/config/read.ts +++ b/lib/commands/config/read.ts @@ -24,6 +24,7 @@ interface FlagsDef { type: string; drive?: string; help: void; + json: boolean; } export default class ConfigReadCmd extends Command { @@ -45,6 +46,7 @@ export default class ConfigReadCmd extends Command { type: cf.deviceType, drive: cf.driveOrImg, help: cf.help, + json: cf.json, }; public static authenticated = true; @@ -63,7 +65,11 @@ export default class ConfigReadCmd extends Command { const config = await import('balena-config-json'); const configJSON = await config.read(drive, options.type); - const prettyjson = await import('prettyjson'); - console.info(prettyjson.render(configJSON)); + if (options.json) { + console.log(JSON.stringify(configJSON, null, 4)); + } else { + const prettyjson = await import('prettyjson'); + console.log(prettyjson.render(configJSON)); + } } }