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
29 changes: 0 additions & 29 deletions packages/edge/src/commands/edge/channels/update.ts

This file was deleted.

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

import { type Channel, type ChannelUpdate } from '@smartthings/core-sdk'

import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../../lib/command/api-command.js'
import {
inputAndOutputItem,
inputAndOutputItemBuilder,
type InputAndOutputItemFlags,
} from '../../../lib/command/input-and-output-item.js'
import { chooseChannel } from '../../../lib/command/util/edge/channels-choose.js'
import { tableFieldDefinitions } from '../../../lib/command/util/edge/channels-table.js'


export type CommandArgs =
& APICommandFlags
& InputAndOutputItemFlags
& {
id?: string
}

const command = 'edge:channels:update [id]'

const describe = 'update a channel'

const builder = (yargs: Argv): Argv<CommandArgs> =>
inputAndOutputItemBuilder(apiCommandBuilder(yargs))
.positional('id', { describe: 'id of channel to update', type: 'string' })
.example([
[
'$0 edge:channels:update --input channel.yaml',
'prompt for a channel and update it using the data in channel.yaml',
],
[
'$0 edge:channels:update 0068b912-50fb-439d-a14a-27cc90ca81dc --input channel.json',
'update the specified channel using the data in channel.json',
],
])
.epilog(apiDocsURL('updateChannel'))

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

const id = await chooseChannel(
command,
argv.id,
{ promptMessage: 'Choose a channel to update.', useConfigDefault: true },
)
await inputAndOutputItem<ChannelUpdate, Channel>(
command,
{ tableFieldDefinitions },
(_, channelMods) => command.client.channels.update(id, channelMods),
)
}

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 @@ -70,6 +70,7 @@ import edgeChannelsInvitesDeleteCommand from './edge/channels/invites/delete.js'
import edgeChannelsMetaInfoCommand from './edge/channels/metainfo.js'
import edgeChannelsUnassignCommand from './edge/channels/unassign.js'
import edgeChannelsUnenrollCommand from './edge/channels/unenroll.js'
import edgeChannelsUpdateCommand from './edge/channels/update.js'
import edgeDriversCommand from './edge/drivers.js'
import edgeDriversDefaultCommand from './edge/drivers/default.js'
import edgeDriversDeleteCommand from './edge/drivers/delete.js'
Expand Down Expand Up @@ -203,6 +204,7 @@ export const commands: CommandModule<object, any>[] = [
edgeChannelsMetaInfoCommand,
edgeChannelsUnassignCommand,
edgeChannelsUnenrollCommand,
edgeChannelsUpdateCommand,
edgeDriversCommand,
edgeDriversDefaultCommand,
edgeDriversDeleteCommand,
Expand Down