device-type list: Add --all flag for including no longer supported device types in the list

Change-type: minor
This commit is contained in:
myarmolinsky 2024-09-26 13:09:53 -04:00
parent e5cee648f2
commit 09d52c504d
2 changed files with 23 additions and 3 deletions

View File

@ -1238,6 +1238,10 @@ To use one of the aliases, replace `device-type list` with the alias.
List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
By default, only actively supported device types are listed.
The --all option can be used to list all device types, including those that are
no longer supported by balena.
The --json option is recommended when scripting the output of this command,
because the JSON format is less likely to change and it better represents data
types like lists and empty strings (for example, the ALIASES column contains a
@ -1247,6 +1251,7 @@ list of zero or more values). The 'jq' utility may be helpful in shell scripts
Examples:
$ balena device-type list
$ balena device-type list --all
$ balena device-type list --json
### Options
@ -1255,6 +1260,10 @@ Examples:
produce JSON output instead of tabular output
#### --all
include device types no longer supported by balena
# Devices
## device deactivate

View File

@ -28,6 +28,10 @@ export default class DeviceTypeListCmd extends Command {
List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
By default, only actively supported device types are listed.
The --all option can be used to list all device types, including those that are
no longer supported by balena.
The --json option is recommended when scripting the output of this command,
because the JSON format is less likely to change and it better represents data
types like lists and empty strings (for example, the ALIASES column contains a
@ -36,6 +40,7 @@ export default class DeviceTypeListCmd extends Command {
`;
public static examples = [
'$ balena device-type list',
'$ balena device-type list --all',
'$ balena device-type list --json',
];
@ -45,6 +50,10 @@ export default class DeviceTypeListCmd extends Command {
char: 'j',
description: 'produce JSON output instead of tabular output',
}),
all: Flags.boolean({
description: 'include device types no longer supported by balena',
default: false,
}),
};
public async run() {
@ -59,9 +68,11 @@ export default class DeviceTypeListCmd extends Command {
},
},
} satisfies BalenaSdk.PineOptions<BalenaSdk.DeviceType>;
const dts = (await getBalenaSdk().models.deviceType.getAllSupported(
pineOptions,
)) as Array<
const dts = (
options.all
? await getBalenaSdk().models.deviceType.getAll(pineOptions)
: await getBalenaSdk().models.deviceType.getAllSupported(pineOptions)
) as Array<
BalenaSdk.PineTypedResult<BalenaSdk.DeviceType, typeof pineOptions>
>;
interface DT {