From 6b5c6e072b426a1e9517376ee756afa31ed96cfa Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Tue, 24 Sep 2024 13:56:06 -0400 Subject: [PATCH] Add `key list` alias for `keys` command Change-type: minor --- automation/capitanodoc/capitanodoc.ts | 1 - completion/_balena | 4 +-- completion/balena-completion.bash | 4 +-- docs/balena-cli.md | 33 +++++++++++-------- src/commands/key/list.ts | 8 +++-- tests/commands/help.spec.ts | 2 +- .../pkg/expected-warnings-darwin-arm64.txt | 4 +-- .../pkg/expected-warnings-darwin-x64.txt | 4 +-- .../pkg/expected-warnings-linux-arm64.txt | 4 +-- .../pkg/expected-warnings-linux-x64.txt | 4 +-- .../pkg/expected-warnings-win32-x64.txt | 4 +-- 11 files changed, 40 insertions(+), 32 deletions(-) diff --git a/automation/capitanodoc/capitanodoc.ts b/automation/capitanodoc/capitanodoc.ts index 34045793..acd6d757 100644 --- a/automation/capitanodoc/capitanodoc.ts +++ b/automation/capitanodoc/capitanodoc.ts @@ -59,7 +59,6 @@ const commandHeadings: { [key: string]: string } = { envs: 'Environment Variables', help: 'Help and Version', key: 'SSH Keys', - keys: 'SSH Keys', orgs: 'Organizations', os: 'OS', util: 'Utilities', diff --git a/completion/_balena b/completion/_balena index 101cdd18..18907236 100644 --- a/completion/_balena +++ b/completion/_balena @@ -8,7 +8,7 @@ _balena() { local context state line curcontext="$curcontext" # Valid top-level completions - main_commands=( api-key app block build config deploy device devices env envs fleet internal join key keys leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami ) + main_commands=( api-key app block build config deploy device devices env envs fleet internal join key leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami ) # Sub-completions api_key_cmds=( generate list revoke ) app_cmds=( create ) @@ -19,7 +19,7 @@ _balena() { env_cmds=( add rename rm ) fleet_cmds=( create list pin purge rename restart rm track-latest ) internal_cmds=( osinit ) - key_cmds=( add rm ) + key_cmds=( add list rm ) local_cmds=( configure flash ) os_cmds=( build-config configure download initialize versions ) release_cmds=( finalize invalidate list validate ) diff --git a/completion/balena-completion.bash b/completion/balena-completion.bash index 41e7e127..ebdc98b0 100644 --- a/completion/balena-completion.bash +++ b/completion/balena-completion.bash @@ -7,7 +7,7 @@ _balena_complete() local cur prev # Valid top-level completions - main_commands="api-key app block build config deploy device devices env envs fleet internal join key keys leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami" + main_commands="api-key app block build config deploy device devices env envs fleet internal join key leave local login logout logs notes orgs os preload push release scan settings ssh support tag tags tunnel util version whoami" # Sub-completions api_key_cmds="generate list revoke" app_cmds="create" @@ -18,7 +18,7 @@ _balena_complete() env_cmds="add rename rm" fleet_cmds="create list pin purge rename restart rm track-latest" internal_cmds="osinit" - key_cmds="add rm" + key_cmds="add list rm" local_cmds="configure flash" os_cmds="build-config configure download initialize versions" release_cmds="finalize invalidate list validate" diff --git a/docs/balena-cli.md b/docs/balena-cli.md index 4b074086..2b2c033b 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -296,8 +296,8 @@ are encouraged to regularly update the balena CLI to the latest version. - [key add](#key-add) - [key](#key) + - [key list](#key-list) - [key rm](#key-rm) - - [keys](#keys) - Support @@ -3723,6 +3723,25 @@ balenaCloud ID for the SSH key ### Options +## key list + +### Aliases + +- `keys` + + +To use one of the aliases, replace `key list` with the alias. + +### Description + +List all SSH keys registered in balenaCloud for the logged in user. + +Examples: + + $ balena key list + +### Options + ## key rm ### Description @@ -3748,18 +3767,6 @@ balenaCloud ID for the SSH key answer "yes" to all questions (non interactive use) -## keys - -### Description - -List all SSH keys registered in balenaCloud for the logged in user. - -Examples: - - $ balena keys - -### Options - # Support ## support diff --git a/src/commands/key/list.ts b/src/commands/key/list.ts index 800aa6ff..baef336a 100644 --- a/src/commands/key/list.ts +++ b/src/commands/key/list.ts @@ -19,13 +19,15 @@ import { Command } from '@oclif/core'; import * as cf from '../../utils/common-flags'; import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; -export default class KeysCmd extends Command { +export default class KeyListCmd extends Command { + public static aliases = ['keys']; + public static description = stripIndent` List the SSH keys in balenaCloud. List all SSH keys registered in balenaCloud for the logged in user. `; - public static examples = ['$ balena keys']; + public static examples = ['$ balena key list']; public static flags = { help: cf.help, @@ -34,7 +36,7 @@ export default class KeysCmd extends Command { public static authenticated = true; public async run() { - await this.parse(KeysCmd); + await this.parse(KeyListCmd); const keys = await getBalenaSdk().models.key.getAll(); diff --git a/tests/commands/help.spec.ts b/tests/commands/help.spec.ts index fdd1ad7d..4ae5898d 100644 --- a/tests/commands/help.spec.ts +++ b/tests/commands/help.spec.ts @@ -72,8 +72,8 @@ ADDITIONAL COMMANDS envs list the environment or config variables of an application, device or service key display an SSH key key add [path] add an SSH key to balenaCloud + key list list the SSH keys in balenaCloud key rm remove an SSH key from balenaCloud - keys list the SSH keys in balenaCloud local configure (Re)configure a balenaOS drive or image local flash flash an image to a drive logout logout from balena diff --git a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt index 95b7895a..ac9a59e5 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt @@ -180,10 +180,10 @@ %2: build/commands/key/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js + %2: build/commands/key/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/keys/index.js + %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js diff --git a/tests/test-data/pkg/expected-warnings-darwin-x64.txt b/tests/test-data/pkg/expected-warnings-darwin-x64.txt index 67ada903..e21bbb34 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-x64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-x64.txt @@ -180,10 +180,10 @@ %2: build/commands/key/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js + %2: build/commands/key/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/keys/index.js + %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js diff --git a/tests/test-data/pkg/expected-warnings-linux-arm64.txt b/tests/test-data/pkg/expected-warnings-linux-arm64.txt index 95b7895a..ac9a59e5 100644 --- a/tests/test-data/pkg/expected-warnings-linux-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-arm64.txt @@ -180,10 +180,10 @@ %2: build/commands/key/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js + %2: build/commands/key/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/keys/index.js + %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js diff --git a/tests/test-data/pkg/expected-warnings-linux-x64.txt b/tests/test-data/pkg/expected-warnings-linux-x64.txt index 67ada903..e21bbb34 100644 --- a/tests/test-data/pkg/expected-warnings-linux-x64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-x64.txt @@ -180,10 +180,10 @@ %2: build/commands/key/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/key/rm.js + %2: build/commands/key/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/keys/index.js + %2: build/commands/key/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/leave/index.js diff --git a/tests/test-data/pkg/expected-warnings-win32-x64.txt b/tests/test-data/pkg/expected-warnings-win32-x64.txt index bcd0f11d..b51680c6 100644 --- a/tests/test-data/pkg/expected-warnings-win32-x64.txt +++ b/tests/test-data/pkg/expected-warnings-win32-x64.txt @@ -180,10 +180,10 @@ %2: build\commands\key\index.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json - %2: build\commands\key\rm.js + %2: build\commands\key\list.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json - %2: build\commands\keys\index.js + %2: build\commands\key\rm.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\leave\index.js