balena-cli
Version:
The official balena Command Line Interface
51 lines (49 loc) • 1.76 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const cf = require("../../utils/common-flags");
const lazy_1 = require("../../utils/lazy");
class DeviceRmCmd extends core_1.Command {
async run() {
const { args: params, flags: options } = await this.parse(DeviceRmCmd);
const balena = (0, lazy_1.getBalenaSdk)();
const patterns = await Promise.resolve().then(() => require('../../utils/patterns'));
const uuids = params.uuid.split(',');
await patterns.confirm(options.yes, uuids.length > 1
? `Are you sure you want to delete ${uuids.length} devices?`
: `Are you sure you want to delete device ${uuids[0]} ?`);
for (const uuid of uuids) {
try {
await balena.models.device.remove(uuid);
}
catch (err) {
console.info(`${err.message}, uuid: ${uuid}`);
process.exitCode = 1;
continue;
}
}
}
}
DeviceRmCmd.description = (0, lazy_1.stripIndent) `
Remove one or more devices.
Remove one or more devices from balena.
Note this command asks for confirmation interactively.
You can avoid this by passing the \`--yes\` option.
`;
DeviceRmCmd.examples = [
'$ balena device rm 7cf02a6',
'$ balena device rm 7cf02a6,dc39e52',
'$ balena device rm 7cf02a6 --yes',
];
DeviceRmCmd.args = {
uuid: core_1.Args.string({
description: 'comma-separated list (no blank spaces) of device UUIDs to be removed',
required: true,
}),
};
DeviceRmCmd.flags = {
yes: cf.yes,
};
DeviceRmCmd.authenticated = true;
exports.default = DeviceRmCmd;
//# sourceMappingURL=rm.js.map
;