Add JSON output for pctl devices

This commit is contained in:
Samuel Elliott
2022-03-17 14:59:16 +00:00
parent 006910df44
commit 4de8373e0b
2 changed files with 19 additions and 0 deletions

View File

@@ -196,6 +196,10 @@ nxapi pctl user
```sh
# Show Nintendo Switch consoles in a table
nxapi pctl devices
# JSON
nxapi pctl devices --json
nxapi pctl devices --json-pretty-print
```
#### Daily summaries

View File

@@ -16,6 +16,12 @@ export function builder(yargs: Argv<ParentArguments>) {
}).option('token', {
describe: 'Nintendo Account session token',
type: 'string',
}).option('json', {
describe: 'Output raw JSON',
type: 'boolean',
}).option('json-pretty-print', {
describe: 'Output pretty-printed JSON',
type: 'boolean',
});
}
@@ -33,6 +39,15 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
const devices = await moon.getDevices();
if (argv.jsonPrettyPrint) {
console.log(JSON.stringify(devices, null, 4));
return;
}
if (argv.json) {
console.log(JSON.stringify(devices));
return;
}
const table = new Table({
head: [
'ID',