diff --git a/docs/balena-cli.md b/docs/balena-cli.md index 3d5c2f496..36cfafba8 100644 --- a/docs/balena-cli.md +++ b/docs/balena-cli.md @@ -1678,10 +1678,6 @@ note content device UUID -#### --dev DEV - - - ## device os-update ### Description diff --git a/src/commands/config/generate.ts b/src/commands/config/generate.ts index 202607c1a..9e368922f 100644 --- a/src/commands/config/generate.ts +++ b/src/commands/config/generate.ts @@ -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', diff --git a/src/commands/device/note.ts b/src/commands/device/note.ts index cedbdb811..10dc08c06 100644 --- a/src/commands/device/note.ts +++ b/src/commands/device/note.ts @@ -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'; @@ -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!); } } diff --git a/src/commands/env/list.ts b/src/commands/env/list.ts index 0c3112c17..5aa3c2ac5 100644 --- a/src/commands/env/list.ts +++ b/src/commands/env/list.ts @@ -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'] }, }; diff --git a/src/commands/env/set.ts b/src/commands/env/set.ts index 1c2a6a34a..6d2780c51 100644 --- a/src/commands/env/set.ts +++ b/src/commands/env/set.ts @@ -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, }; diff --git a/src/commands/os/configure.ts b/src/commands/os/configure.ts index c051b040c..7573949a1 100644 --- a/src/commands/os/configure.ts +++ b/src/commands/os/configure.ts @@ -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', diff --git a/src/commands/tag/list.ts b/src/commands/tag/list.ts index 0cc847b2f..22dc9e8c2 100644 --- a/src/commands/tag/list.ts +++ b/src/commands/tag/list.ts @@ -47,7 +47,7 @@ export default class TagListCmd extends Command { exclusive: ['device', 'release'], }, device: { - ...cf.device, + ...cf.device(), exclusive: ['fleet', 'release'], }, release: { diff --git a/src/commands/tag/rm.ts b/src/commands/tag/rm.ts index af2e863b6..959c9db89 100644 --- a/src/commands/tag/rm.ts +++ b/src/commands/tag/rm.ts @@ -50,7 +50,7 @@ export default class TagRmCmd extends Command { exclusive: ['device', 'release'], }, device: { - ...cf.device, + ...cf.device(), exclusive: ['fleet', 'release'], }, release: { diff --git a/src/commands/tag/set.ts b/src/commands/tag/set.ts index 9793667b9..eb1fe11cd 100644 --- a/src/commands/tag/set.ts +++ b/src/commands/tag/set.ts @@ -64,7 +64,7 @@ export default class TagSetCmd extends Command { exclusive: ['device', 'release'], }, device: { - ...cf.device, + ...cf.device(), exclusive: ['fleet', 'release'], }, release: { diff --git a/src/utils/common-flags.ts b/src/utils/common-flags.ts index e44e64e49..8f3fbbf45 100644 --- a/src/utils/common-flags.ts +++ b/src/utils/common-flags.ts @@ -28,10 +28,13 @@ export const fleet = (extraOpts?: Partial) => ...extraOpts, }); -export const device = Flags.string({ - char: 'd', - description: 'device UUID', -}); +// eslint-disable-next-line id-denylist +export const device = (extraOpts?: Partial) => + Flags.string({ + char: 'd', + description: 'device UUID', + ...extraOpts, + }); export const quiet = Flags.boolean({ char: 'q',