Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions packages/cli/src/commands/deviceprofiles/delete.ts

This file was deleted.

43 changes: 43 additions & 0 deletions src/commands/deviceprofiles/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs'

import { apiDocsURL } from '../../lib/command/api-command.js'
import {
apiOrganizationCommand,
apiOrganizationCommandBuilder,
type APIOrganizationCommandFlags,
} from '../../lib/command/api-organization-command.js'
import { chooseDeviceProfile } from '../../lib/command/util/deviceprofiles-choose.js'


export type CommandArgs =
& APIOrganizationCommandFlags
& {
id?: string
}

const command = 'deviceprofiles:delete [id]'

const describe = 'delete a device profile'

const builder = (yargs: Argv): Argv<CommandArgs> =>
apiOrganizationCommandBuilder(yargs)
.positional('id', { describe: 'device profile id', type: 'string' })
.example([
['$0 deviceprofiles:delete', 'prompt for a device profile and delete it'],
[
'$0 deviceprofiles:delete 63b8c91e-9686-4c43-9afb-fbd9f77e3bb0',
'delete the device profile with the specified id',
],
])
.epilog(apiDocsURL('deleteDeviceProfile'))

const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => {
const command = await apiOrganizationCommand(argv)

const id = await chooseDeviceProfile(command, argv.id)
await command.client.deviceProfiles.delete(id)
console.log(`Device profile ${id} deleted.`)
}

const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler }
export default cmd
2 changes: 2 additions & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import devicepreferencesTranslationsCreateCommand from './devicepreferences/tran
import devicepreferencesTranslationsUpdateCommand from './devicepreferences/translations/update.js'
import deviceprofilesCommand from './deviceprofiles.js'
import deviceprofilesCreateCommand from './deviceprofiles/create.js'
import deviceprofilesDeleteCommand from './deviceprofiles/delete.js'
import deviceprofilesDeviceConfigCommand from './deviceprofiles/device-config.js'
import deviceprofilesPresentationCommand from './deviceprofiles/presentation.js'
import deviceprofilesPublishCommand from './deviceprofiles/publish.js'
Expand Down Expand Up @@ -152,6 +153,7 @@ export const commands: CommandModule<object, any>[] = [
devicepreferencesTranslationsUpdateCommand,
deviceprofilesCommand,
deviceprofilesCreateCommand,
deviceprofilesDeleteCommand,
deviceprofilesDeviceConfigCommand,
deviceprofilesPresentationCommand,
deviceprofilesPublishCommand,
Expand Down