From 5eba175bf1a0e016b98757848e0c345489f686c1 Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Wed, 25 Sep 2024 07:47:38 -0400 Subject: [PATCH] Add alias `tag list` for `tags` command Change-type: minor --- completion/_balena | 4 +- completion/balena-completion.bash | 4 +- docs/balena-cli.md | 85 ++++++++++--------- src/commands/tag/list.ts | 18 ++-- tests/commands/help.spec.ts | 6 +- .../pkg/expected-warnings-darwin-arm64.txt | 6 +- .../pkg/expected-warnings-darwin-x64.txt | 6 +- .../pkg/expected-warnings-linux-arm64.txt | 6 +- .../pkg/expected-warnings-linux-x64.txt | 6 +- .../pkg/expected-warnings-win32-x64.txt | 6 +- 10 files changed, 78 insertions(+), 69 deletions(-) diff --git a/completion/_balena b/completion/_balena index 0673af7e98..f85d784eda 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 fleet internal join leave local login logout logs notes orgs os preload push release scan settings ssh ssh-key support tag tags tunnel util version whoami ) + main_commands=( api-key app block build config deploy device devices env fleet internal join leave local login logout logs notes orgs os preload push release scan settings ssh ssh-key support tag tunnel util version whoami ) # Sub-completions api_key_cmds=( generate list revoke ) app_cmds=( create ) @@ -23,7 +23,7 @@ _balena() { os_cmds=( build-config configure download initialize versions ) release_cmds=( finalize invalidate list validate ) ssh_key_cmds=( add list rm ) - tag_cmds=( rm set ) + tag_cmds=( list rm set ) _arguments -C \ diff --git a/completion/balena-completion.bash b/completion/balena-completion.bash index 08e272e306..664ff1faca 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 fleet internal join leave local login logout logs notes orgs os preload push release scan settings ssh ssh-key support tag tags tunnel util version whoami" + main_commands="api-key app block build config deploy device devices env fleet internal join leave local login logout logs notes orgs os preload push release scan settings ssh ssh-key support tag tunnel util version whoami" # Sub-completions api_key_cmds="generate list revoke" app_cmds="create" @@ -22,7 +22,7 @@ _balena_complete() os_cmds="build-config configure download initialize versions" release_cmds="finalize invalidate list validate" ssh_key_cmds="add list rm" - tag_cmds="rm set" + tag_cmds="list rm set" diff --git a/docs/balena-cli.md b/docs/balena-cli.md index 2e21977864..a46369936b 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -305,9 +305,9 @@ are encouraged to regularly update the balena CLI to the latest version. - Tags + - [tag list](#tag-list) - [tag rm](#tag-rm) - [tag set](#tag-set) - - [tags](#tags) - Utilities @@ -3850,11 +3850,18 @@ length of time to enable support for, in (h)ours or (d)ays, e.g. 12h, 2d # Tags -## tag rm +## tag list + +### Aliases + +- `tags` + + +To use one of the aliases, replace `tag list` with the alias. ### Description -Remove a tag from a fleet, device or release. +List all tags and their values for the specified fleet, device or release. Fleets may be specified by fleet name or slug. Fleet slugs are the recommended option, as they are unique and unambiguous. Slugs can be @@ -3868,17 +3875,11 @@ environments). Examples: - $ balena tag rm myTagKey --fleet MyFleet - $ balena tag rm myTagKey -f myorg/myfleet - $ balena tag rm myTagKey --device 7cf02a6 - $ balena tag rm myTagKey --release 1234 - $ balena tag rm myTagKey --release b376b0e544e9429483b656490e5b9443b4349bd6 - -### Arguments - -#### TAGKEY - -the key string of the tag + $ balena tag list --fleet MyFleet + $ balena tag list -f myorg/myfleet + $ balena tag list --device 7cf02a6 + $ balena tag list --release 1234 + $ balena tag list --release b376b0e544e9429483b656490e5b9443b4349bd6 ### Options @@ -3894,15 +3895,11 @@ device UUID release id -## tag set +## tag rm ### Description -Set a tag on a fleet, device or release. - -You can optionally provide a value to be associated with the created -tag, as an extra argument after the tag key. If a value isn't -provided, a tag with an empty value is created. +Remove a tag from a fleet, device or release. Fleets may be specified by fleet name or slug. Fleet slugs are the recommended option, as they are unique and unambiguous. Slugs can be @@ -3916,14 +3913,11 @@ environments). Examples: - $ balena tag set mySimpleTag --fleet MyFleet - $ balena tag set mySimpleTag -f myorg/myfleet - $ balena tag set myCompositeTag myTagValue --fleet MyFleet - $ balena tag set myCompositeTag myTagValue --device 7cf02a6 - $ balena tag set myCompositeTag "my tag value with whitespaces" --device 7cf02a6 - $ balena tag set myCompositeTag myTagValue --release 1234 - $ balena tag set myCompositeTag --release 1234 - $ balena tag set myCompositeTag --release b376b0e544e9429483b656490e5b9443b4349bd6 + $ balena tag rm myTagKey --fleet MyFleet + $ balena tag rm myTagKey -f myorg/myfleet + $ balena tag rm myTagKey --device 7cf02a6 + $ balena tag rm myTagKey --release 1234 + $ balena tag rm myTagKey --release b376b0e544e9429483b656490e5b9443b4349bd6 ### Arguments @@ -3931,10 +3925,6 @@ Examples: the key string of the tag -#### VALUE - -the optional value associated with the tag - ### Options #### -f, --fleet FLEET @@ -3949,11 +3939,15 @@ device UUID release id -## tags +## tag set ### Description -List all tags and their values for the specified fleet, device or release. +Set a tag on a fleet, device or release. + +You can optionally provide a value to be associated with the created +tag, as an extra argument after the tag key. If a value isn't +provided, a tag with an empty value is created. Fleets may be specified by fleet name or slug. Fleet slugs are the recommended option, as they are unique and unambiguous. Slugs can be @@ -3967,11 +3961,24 @@ environments). Examples: - $ balena tags --fleet MyFleet - $ balena tags -f myorg/myfleet - $ balena tags --device 7cf02a6 - $ balena tags --release 1234 - $ balena tags --release b376b0e544e9429483b656490e5b9443b4349bd6 + $ balena tag set mySimpleTag --fleet MyFleet + $ balena tag set mySimpleTag -f myorg/myfleet + $ balena tag set myCompositeTag myTagValue --fleet MyFleet + $ balena tag set myCompositeTag myTagValue --device 7cf02a6 + $ balena tag set myCompositeTag "my tag value with whitespaces" --device 7cf02a6 + $ balena tag set myCompositeTag myTagValue --release 1234 + $ balena tag set myCompositeTag --release 1234 + $ balena tag set myCompositeTag --release b376b0e544e9429483b656490e5b9443b4349bd6 + +### Arguments + +#### TAGKEY + +the key string of the tag + +#### VALUE + +the optional value associated with the tag ### Options diff --git a/src/commands/tag/list.ts b/src/commands/tag/list.ts index 79b90229ee..509ed9e83f 100644 --- a/src/commands/tag/list.ts +++ b/src/commands/tag/list.ts @@ -21,7 +21,9 @@ import * as cf from '../../utils/common-flags'; import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy'; import { applicationIdInfo } from '../../utils/messages'; -export default class TagsCmd extends Command { +export default class TagListCmd extends Command { + public static aliases = ['tags']; + public static description = stripIndent` List all tags for a fleet, device or release. @@ -31,11 +33,11 @@ export default class TagsCmd extends Command { `; public static examples = [ - '$ balena tags --fleet MyFleet', - '$ balena tags -f myorg/myfleet', - '$ balena tags --device 7cf02a6', - '$ balena tags --release 1234', - '$ balena tags --release b376b0e544e9429483b656490e5b9443b4349bd6', + '$ balena tag list --fleet MyFleet', + '$ balena tag list -f myorg/myfleet', + '$ balena tag list --device 7cf02a6', + '$ balena tag list --release 1234', + '$ balena tag list --release b376b0e544e9429483b656490e5b9443b4349bd6', ]; public static flags = { @@ -57,7 +59,7 @@ export default class TagsCmd extends Command { public static authenticated = true; public async run() { - const { flags: options } = await this.parse(TagsCmd); + const { flags: options } = await this.parse(TagListCmd); const balena = getBalenaSdk(); @@ -105,6 +107,6 @@ export default class TagsCmd extends Command { See the help page for examples: - $ balena help tags + $ balena help tag list `; } diff --git a/tests/commands/help.spec.ts b/tests/commands/help.spec.ts index e9268c755f..48385e3d6e 100644 --- a/tests/commands/help.spec.ts +++ b/tests/commands/help.spec.ts @@ -84,9 +84,9 @@ ADDITIONAL COMMANDS os initialize initialize an os image for a device os versions show available balenaOS versions for the given device type settings print current settings - tag rm remove a tag from an application, device or release - tag set [value] set a tag on an application, device or release - tags list all tags for an application, device or release + tag list list all tags for a app, block, fleet, device or release + tag rm remove a tag from an app, block, fleet, device or release + tag set [value] set a tag on an app, block, fleet, device or release util available-drives list available drives version display version information for the balena CLI and/or Node.js whoami display account information for current user diff --git a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt index 44d435403b..0c9d646721 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-arm64.txt @@ -258,13 +258,13 @@ %2: build/commands/support/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/rm.js + %2: build/commands/tag/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/set.js + %2: build/commands/tag/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tags/index.js + %2: build/commands/tag/set.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tunnel/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 92d5ebaaad..f9f6649d35 100644 --- a/tests/test-data/pkg/expected-warnings-darwin-x64.txt +++ b/tests/test-data/pkg/expected-warnings-darwin-x64.txt @@ -258,13 +258,13 @@ %2: build/commands/support/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/rm.js + %2: build/commands/tag/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/set.js + %2: build/commands/tag/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tags/index.js + %2: build/commands/tag/set.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tunnel/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 44d435403b..0c9d646721 100644 --- a/tests/test-data/pkg/expected-warnings-linux-arm64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-arm64.txt @@ -258,13 +258,13 @@ %2: build/commands/support/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/rm.js + %2: build/commands/tag/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/set.js + %2: build/commands/tag/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tags/index.js + %2: build/commands/tag/set.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tunnel/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 92d5ebaaad..f9f6649d35 100644 --- a/tests/test-data/pkg/expected-warnings-linux-x64.txt +++ b/tests/test-data/pkg/expected-warnings-linux-x64.txt @@ -258,13 +258,13 @@ %2: build/commands/support/index.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/rm.js + %2: build/commands/tag/list.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tag/set.js + %2: build/commands/tag/rm.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json - %2: build/commands/tags/index.js + %2: build/commands/tag/set.js > Warning Entry 'main' not found in %1 %1: node_modules/@oclif/core/package.json %2: build/commands/tunnel/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 a563915398..6961872a7f 100644 --- a/tests/test-data/pkg/expected-warnings-win32-x64.txt +++ b/tests/test-data/pkg/expected-warnings-win32-x64.txt @@ -258,13 +258,13 @@ %2: build\commands\support\index.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json - %2: build\commands\tag\rm.js + %2: build\commands\tag\list.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json - %2: build\commands\tag\set.js + %2: build\commands\tag\rm.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json - %2: build\commands\tags\index.js + %2: build\commands\tag\set.js > Warning Entry 'main' not found in %1 %1: node_modules\@oclif\core\package.json %2: build\commands\tunnel\index.js