Skip to content

Commit

Permalink
Add alias tag list for tags command
Browse files Browse the repository at this point in the history
Change-type: minor
  • Loading branch information
myarmolinsky committed Oct 18, 2024
1 parent bd1b71b commit 5eba175
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 69 deletions.
4 changes: 2 additions & 2 deletions completion/_balena
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand All @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions completion/balena-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"



Expand Down
85 changes: 46 additions & 39 deletions docs/balena-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -3916,25 +3913,18 @@ 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

#### TAGKEY

the key string of the tag

#### VALUE

the optional value associated with the tag

### Options

#### -f, --fleet FLEET
Expand All @@ -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
Expand All @@ -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

Expand Down
18 changes: 10 additions & 8 deletions src/commands/tag/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 = {
Expand All @@ -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();

Expand Down Expand Up @@ -105,6 +107,6 @@ export default class TagsCmd extends Command {
See the help page for examples:
$ balena help tags
$ balena help tag list
`;
}
6 changes: 3 additions & 3 deletions tests/commands/help.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ ADDITIONAL COMMANDS
os initialize <image> initialize an os image for a device
os versions <type> show available balenaOS versions for the given device type
settings print current settings
tag rm <tagKey> remove a tag from an application, device or release
tag set <tagKey> [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 <tagKey> remove a tag from an app, block, fleet, device or release
tag set <tagKey> [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
Expand Down
6 changes: 3 additions & 3 deletions tests/test-data/pkg/expected-warnings-darwin-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test-data/pkg/expected-warnings-darwin-x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test-data/pkg/expected-warnings-linux-arm64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test-data/pkg/expected-warnings-linux-x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/test-data/pkg/expected-warnings-win32-x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5eba175

Please sign in to comment.