Skip to content

Commit

Permalink
balena device note
Browse files Browse the repository at this point in the history
Change-type: patch
  • Loading branch information
myarmolinsky committed Nov 5, 2024
1 parent 01a81b3 commit ef6d37f
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 35 deletions.
4 changes: 0 additions & 4 deletions docs/balena-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1678,10 +1678,6 @@ note content

device UUID

#### --dev DEV



## device os-update

### Description
Expand Down
2 changes: 1 addition & 1 deletion src/commands/config/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class ConfigGenerateCmd extends Command {
dev: cf.dev,
secureBoot: cf.secureBoot,
device: {
...cf.device,
...cf.device(),
exclusive: [
'fleet',
'provisioning-key-name',
Expand Down
28 changes: 8 additions & 20 deletions src/commands/device/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
* limitations under the License.
*/

import { Flags, Args, Command } from '@oclif/core';
import { ExpectedError } from '../../errors';
import { Args, Command } from '@oclif/core';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, stripIndent } from '../../utils/lazy';

Expand All @@ -41,35 +40,24 @@ export default class DeviceNoteCmd extends Command {
public static args = {
note: Args.string({
description: 'note content',
required: true,
}),
};

public static flags = {
device: { exclusive: ['dev'], ...cf.device },
dev: Flags.string({
exclusive: ['device'],
hidden: true,
}),
device: cf.device({ required: true }),
};

public static authenticated = true;

public async run() {
const { args: params, flags: options } = await this.parse(DeviceNoteCmd);

if (params.note?.length === 0) {
throw new ExpectedError('Missing note content');
}

options.device = options.device || options.dev;
delete options.dev;

if (options.device == null || options.device.length === 0) {
throw new ExpectedError('Missing device UUID (--device)');
}
const {
args: params,
flags: { device },
} = await this.parse(DeviceNoteCmd);

const balena = getBalenaSdk();

return balena.models.device.setNote(options.device, params.note ?? '');
return balena.models.device.setNote(device!, params.note!);
}
}
2 changes: 1 addition & 1 deletion src/commands/env/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class EnvListCmd extends Command {
description: 'show configuration variables only',
exclusive: ['service'],
}),
device: { ...cf.device, exclusive: ['fleet'] },
device: { ...cf.device(), exclusive: ['fleet'] },
json: cf.json,
service: { ...cf.service, exclusive: ['config'] },
};
Expand Down
2 changes: 1 addition & 1 deletion src/commands/env/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default class EnvSetCmd extends Command {

public static flags = {
fleet: { ...cf.fleet(), exclusive: ['device'] },
device: { ...cf.device, exclusive: ['fleet'] },
device: { ...cf.device(), exclusive: ['fleet'] },
quiet: cf.quiet,
service: cf.service,
};
Expand Down
2 changes: 1 addition & 1 deletion src/commands/os/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class OsConfigureCmd extends Command {
dev: cf.dev,
secureBoot: cf.secureBoot,
device: {
...cf.device,
...cf.device(),
exclusive: [
'fleet',
'provisioning-key-name',
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tag/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class TagListCmd extends Command {
exclusive: ['device', 'release'],
},
device: {
...cf.device,
...cf.device(),
exclusive: ['fleet', 'release'],
},
release: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tag/rm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class TagRmCmd extends Command {
exclusive: ['device', 'release'],
},
device: {
...cf.device,
...cf.device(),
exclusive: ['fleet', 'release'],
},
release: {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/tag/set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class TagSetCmd extends Command {
exclusive: ['device', 'release'],
},
device: {
...cf.device,
...cf.device(),
exclusive: ['fleet', 'release'],
},
release: {
Expand Down
11 changes: 7 additions & 4 deletions src/utils/common-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ export const fleet = (extraOpts?: Partial<typeof Flags.string>) =>
...extraOpts,
});

export const device = Flags.string({
char: 'd',
description: 'device UUID',
});
// eslint-disable-next-line id-denylist
export const device = (extraOpts?: Partial<typeof Flags.string>) =>
Flags.string({
char: 'd',
description: 'device UUID',
...extraOpts,
});

export const quiet = Flags.boolean({
char: 'q',
Expand Down

0 comments on commit ef6d37f

Please sign in to comment.