mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-08-20 01:25:31 -05:00
Add JSON output for pctl devices
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user