Add alias device-type list for command devices supported

Change-type: minor
This commit is contained in:
myarmolinsky 2024-09-26 13:01:19 -04:00
parent 98a6b431d9
commit e5cee648f2
20 changed files with 88 additions and 74 deletions

View File

@ -8,14 +8,14 @@ _balena() {
local context state line curcontext="$curcontext"
# Valid top-level completions
main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami )
main_commands=( api-key app block build config deploy device device-type env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami )
# Sub-completions
api_key_cmds=( generate list revoke )
app_cmds=( create )
block_cmds=( create )
config_cmds=( generate inject read reconfigure write )
device_type_cmds=( list )
device_cmds=( deactivate detect identify init list local-mode logs move note os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet tunnel )
devices_cmds=( supported )
env_cmds=( list rename rm set )
fleet_cmds=( create list pin purge rename restart rm track-latest )
internal_cmds=( osinit )
@ -55,12 +55,12 @@ _balena_sec_cmds() {
"config")
_describe -t config_cmds 'config_cmd' config_cmds "$@" && ret=0
;;
"device-type")
_describe -t device_type_cmds 'device-type_cmd' device_type_cmds "$@" && ret=0
;;
"device")
_describe -t device_cmds 'device_cmd' device_cmds "$@" && ret=0
;;
"devices")
_describe -t devices_cmds 'devices_cmd' devices_cmds "$@" && ret=0
;;
"env")
_describe -t env_cmds 'env_cmd' env_cmds "$@" && ret=0
;;

View File

@ -7,14 +7,14 @@ _balena_complete()
local cur prev
# Valid top-level completions
main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami"
main_commands="api-key app block build config deploy device device-type env fleet internal join leave local login logout organization os preload push release settings ssh-key support tag util version whoami"
# Sub-completions
api_key_cmds="generate list revoke"
app_cmds="create"
block_cmds="create"
config_cmds="generate inject read reconfigure write"
device_type_cmds="list"
device_cmds="deactivate detect identify init list local-mode logs move note os-update pin public-url purge reboot register rename restart rm shutdown ssh start-service stop-service track-fleet tunnel"
devices_cmds="supported"
env_cmds="list rename rm set"
fleet_cmds="create list pin purge rename restart rm track-latest"
internal_cmds="osinit"
@ -49,12 +49,12 @@ _balena_complete()
config)
COMPREPLY=( $(compgen -W "$config_cmds" -- $cur) )
;;
device-type)
COMPREPLY=( $(compgen -W "$device_type_cmds" -- $cur) )
;;
device)
COMPREPLY=( $(compgen -W "$device_cmds" -- $cur) )
;;
devices)
COMPREPLY=( $(compgen -W "$devices_cmds" -- $cur) )
;;
env)
COMPREPLY=( $(compgen -W "$env_cmds" -- $cur) )
;;

View File

@ -193,6 +193,10 @@ are encouraged to regularly update the balena CLI to the latest version.
- [build](#build)
- [deploy](#deploy)
- Device-type
- [device-type list](#device-type-list)
- Devices
- [device deactivate](#device-deactivate)
@ -220,7 +224,6 @@ are encouraged to regularly update the balena CLI to the latest version.
- [device stop-service](#device-stop-service)
- [device track-fleet](#device-track-fleet)
- [device tunnel](#device-tunnel)
- [devices supported](#devices-supported)
- Environment Variables
@ -397,7 +400,7 @@ should be provided. Organization handles can be listed with the
`balena organization list` command.
The app's default device type is specified with the `--type` option.
The `balena devices supported` command can be used to list the available
The `balena device-type list` command can be used to list the available
device types.
Interactive dropdowns will be shown for selection if no device type or
@ -426,7 +429,7 @@ handle of the organization the app should belong to
#### -t, --type TYPE
app device type (Check available types with `balena devices supported`)
app device type (Check available types with `balena device-type list`)
# Authentication
@ -527,7 +530,7 @@ should be provided. Organization handles can be listed with the
`balena organization list` command.
The block's default device type is specified with the `--type` option.
The `balena devices supported` command can be used to list the available
The `balena device-type list` command can be used to list the available
device types.
Interactive dropdowns will be shown for selection if no device type or
@ -556,7 +559,7 @@ handle of the organization the block should belong to
#### -t, --type TYPE
block device type (Check available types with `balena devices supported`)
block device type (Check available types with `balena device-type list`)
# Config
@ -638,7 +641,7 @@ custom device key - note that this is only supported on balenaOS 2.0.3+
#### --deviceType DEVICETYPE
device type slug (run 'balena devices supported' for possible values)
device type slug (run 'balena device-type list' for possible values)
#### --generate-device-api-key
@ -1220,6 +1223,38 @@ Docker host TLS certificate file
Docker host TLS key file
# Device-type
## device-type list
### Aliases
- `devices supported`
To use one of the aliases, replace `device-type list` with the alias.
### Description
List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
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
list of zero or more values). The 'jq' utility may be helpful in shell scripts
(https://stedolan.github.io/jq/manual/).
Examples:
$ balena device-type list
$ balena device-type list --json
### Options
#### -j, --json
produce JSON output instead of tabular output
# Devices
## device deactivate
@ -1826,7 +1861,7 @@ custom uuid
#### --deviceType DEVICETYPE
device type slug (run 'balena devices supported' for possible values)
device type slug (run 'balena device-type list' for possible values)
## device rename
@ -2138,29 +2173,6 @@ device UUID or fleet name/slug
port mapping in the format <remotePort>[:[localIP:]localPort]
## devices supported
### Description
List the supported device types (like 'raspberrypi3' or 'intel-nuc').
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
list of zero or more values). The 'jq' utility may be helpful in shell scripts
(https://stedolan.github.io/jq/manual/).
Examples:
$ balena devices supported
$ balena devices supported --json
### Options
#### -j, --json
produce JSON output instead of tabular output
# Environment Variables
## env list
@ -2479,7 +2491,7 @@ should be provided. Organization handles can be listed with the
`balena organization list` command.
The fleet's default device type is specified with the `--type` option.
The `balena devices supported` command can be used to list the available
The `balena device-type list` command can be used to list the available
device types.
Interactive dropdowns will be shown for selection if no device type or
@ -2508,7 +2520,7 @@ handle of the organization the fleet should belong to
#### -t, --type TYPE
fleet device type (Check available types with `balena devices supported`)
fleet device type (Check available types with `balena device-type list`)
## fleet
@ -2992,7 +3004,7 @@ expiry date assigned to generated provisioning api key (format: YYYY-MM-DD)
### Description
Download an unconfigured OS image for the specified device type.
Check available device types with 'balena devices supported'.
Check available device types with 'balena device-type list'.
Note: Currently this command only works with balenaCloud, not openBalena.
If using openBalena, please download the OS from: https://www.balena.io/os/
@ -3071,7 +3083,7 @@ path to OS image
#### -t, --type TYPE
device type (Check available types with `balena devices supported`)
device type (Check available types with `balena device-type list`)
#### -d, --drive DRIVE
@ -3088,7 +3100,7 @@ answer "yes" to all questions (non interactive use)
### Description
Show the available balenaOS versions for the given device type.
Check available types with `balena devices supported`.
Check available types with `balena device-type list`.
balenaOS ESR versions can be listed with the '--esr' option. See also:
https://www.balena.io/docs/reference/OS/extended-support-release/

View File

@ -31,7 +31,7 @@ export default class AppCreateCmd extends Command {
\`balena organization list\` command.
The app's default device type is specified with the \`--type\` option.
The \`balena devices supported\` command can be used to list the available
The \`balena device-type list\` command can be used to list the available
device types.
Interactive dropdowns will be shown for selection if no device type or
@ -62,7 +62,7 @@ export default class AppCreateCmd extends Command {
type: Flags.string({
char: 't',
description:
'app device type (Check available types with `balena devices supported`)',
'app device type (Check available types with `balena device-type list`)',
}),
help: cf.help,
};

View File

@ -31,7 +31,7 @@ export default class BlockCreateCmd extends Command {
\`balena organization list\` command.
The block's default device type is specified with the \`--type\` option.
The \`balena devices supported\` command can be used to list the available
The \`balena device-type list\` command can be used to list the available
device types.
Interactive dropdowns will be shown for selection if no device type or
@ -62,7 +62,7 @@ export default class BlockCreateCmd extends Command {
type: Flags.string({
char: 't',
description:
'block device type (Check available types with `balena devices supported`)',
'block device type (Check available types with `balena device-type list`)',
}),
help: cf.help,
};

View File

@ -82,7 +82,7 @@ export default class ConfigGenerateCmd extends Command {
}),
deviceType: Flags.string({
description:
"device type slug (run 'balena devices supported' for possible values)",
"device type slug (run 'balena device-type list' for possible values)",
}),
'generate-device-api-key': Flags.boolean({
description: 'generate a fresh device key for the device',

View File

@ -20,11 +20,13 @@ import * as _ from 'lodash';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
export default class DevicesSupportedCmd extends Command {
public static description = stripIndent`
List the supported device types (like 'raspberrypi3' or 'intel-nuc').
export default class DeviceTypeListCmd extends Command {
public static aliases = ['devices supported'];
List the supported device types (like 'raspberrypi3' or 'intel-nuc').
public static description = stripIndent`
List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
List the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
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
@ -33,8 +35,8 @@ export default class DevicesSupportedCmd extends Command {
(https://stedolan.github.io/jq/manual/).
`;
public static examples = [
'$ balena devices supported',
'$ balena devices supported --json',
'$ balena device-type list',
'$ balena device-type list --json',
];
public static flags = {
@ -46,7 +48,7 @@ export default class DevicesSupportedCmd extends Command {
};
public async run() {
const { flags: options } = await this.parse(DevicesSupportedCmd);
const { flags: options } = await this.parse(DeviceTypeListCmd);
const pineOptions = {
$select: ['slug', 'name'],
$expand: {

View File

@ -50,7 +50,7 @@ export default class DeviceRegisterCmd extends Command {
}),
deviceType: Flags.string({
description:
"device type slug (run 'balena devices supported' for possible values)",
"device type slug (run 'balena device-type list' for possible values)",
}),
help: cf.help,
};

View File

@ -31,7 +31,7 @@ export default class FleetCreateCmd extends Command {
\`balena organization list\` command.
The fleet's default device type is specified with the \`--type\` option.
The \`balena devices supported\` command can be used to list the available
The \`balena device-type list\` command can be used to list the available
device types.
Interactive dropdowns will be shown for selection if no device type or
@ -62,7 +62,7 @@ export default class FleetCreateCmd extends Command {
type: Flags.string({
char: 't',
description:
'fleet device type (Check available types with `balena devices supported`)',
'fleet device type (Check available types with `balena device-type list`)',
}),
help: cf.help,
};

View File

@ -24,7 +24,7 @@ export default class OsDownloadCmd extends Command {
Download an unconfigured OS image.
Download an unconfigured OS image for the specified device type.
Check available device types with 'balena devices supported'.
Check available device types with 'balena device-type list'.
Note: Currently this command only works with balenaCloud, not openBalena.
If using openBalena, please download the OS from: https://www.balena.io/os/

View File

@ -24,7 +24,7 @@ export default class OsVersionsCmd extends Command {
Show available balenaOS versions for the given device type.
Show the available balenaOS versions for the given device type.
Check available types with \`balena devices supported\`.
Check available types with \`balena device-type list\`.
balenaOS ESR versions can be listed with the '--esr' option. See also:
https://www.balena.io/docs/reference/OS/extended-support-release/

View File

@ -190,7 +190,7 @@ const messages: {
const slug = error.deviceTypeSlug ? `"${error.deviceTypeSlug}"` : 'slug';
return stripIndent`
Device type ${slug} not recognized. Perhaps misspelled?
Check available device types with "balena devices supported"`;
Check available device types with "balena device-type list"`;
},
};

View File

@ -94,7 +94,7 @@ export const driveOrImg = Flags.string({
export const deviceType = Flags.string({
description:
'device type (Check available types with `balena devices supported`)',
'device type (Check available types with `balena device-type list`)',
char: 't',
required: true,
});

View File

@ -20,7 +20,7 @@ import { expect } from 'chai';
import { BalenaAPIMock } from '../../nock/balena-api-mock';
import { cleanOutput, runCommand } from '../../helpers';
describe('balena devices supported', function () {
describe('balena device-type list', function () {
let api: BalenaAPIMock;
beforeEach(() => {
@ -34,9 +34,9 @@ describe('balena devices supported', function () {
});
it('should print help text with the -h flag', async () => {
const { out, err } = await runCommand('devices supported -h');
const { out, err } = await runCommand('device-type list -h');
expect(cleanOutput(out)).to.contain('$ balena devices supported');
expect(cleanOutput(out)).to.contain('$ balena device-type list');
expect(err).to.eql([]);
});
@ -44,7 +44,7 @@ describe('balena devices supported', function () {
it('should list currently supported devices, with correct filtering', async () => {
api.expectGetDeviceTypes();
const { out, err } = await runCommand('devices supported');
const { out, err } = await runCommand('device-type list');
const lines = cleanOutput(out, true);

View File

@ -64,7 +64,7 @@ ADDITIONAL COMMANDS
device shutdown shutdown a device
device ssh SSH into the host or application container of a device
device tunnel tunnel local ports to your balenaOS device
devices supported list the supported device types (like 'raspberrypi3' or 'intel-nuc')
device-type list list the device types supported by balena (like 'raspberrypi3' or 'intel-nuc').
env set add or update env or config variable to application(s), device(s) or service(s)
env list list the environment or config variables of an application, device or service
env rename change the value of a config or env var for an app, device or service

View File

@ -141,7 +141,7 @@
%2: build/commands/device/tunnel.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/devices/supported.js
%2: build/commands/device-type/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/env/list.js

View File

@ -141,7 +141,7 @@
%2: build/commands/device/tunnel.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/devices/supported.js
%2: build/commands/device-type/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/env/list.js

View File

@ -141,7 +141,7 @@
%2: build/commands/device/tunnel.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/devices/supported.js
%2: build/commands/device-type/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/env/list.js

View File

@ -141,7 +141,7 @@
%2: build/commands/device/tunnel.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/devices/supported.js
%2: build/commands/device-type/list.js
> Warning Entry 'main' not found in %1
%1: node_modules/@oclif/core/package.json
%2: build/commands/env/list.js

View File

@ -141,7 +141,7 @@
%2: build\commands\device\tunnel.js
> Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json
%2: build\commands\devices\supported.js
%2: build\commands\device-type\list.js
> Warning Entry 'main' not found in %1
%1: node_modules\@oclif\core\package.json
%2: build\commands\env\list.js