Skip to content

refactor: convert edge:channels:(un)?assign command to yargs#771

Merged
rossiam merged 2 commits into
SmartThingsCommunity:yargsfrom
rossiam:yargs-edge-channels-unassign
Jun 17, 2025
Merged

refactor: convert edge:channels:(un)?assign command to yargs#771
rossiam merged 2 commits into
SmartThingsCommunity:yargsfrom
rossiam:yargs-edge-channels-unassign

Conversation

@rossiam

@rossiam rossiam commented Jun 16, 2025

Copy link
Copy Markdown
Collaborator
  • converted edge:channels:unassign and edge:channels:assign commands to yargs
  • updated relevant unit tests
  • updated chooseChannel function to support a specified driver id so if the user specified a driver id but no channel, we only present them with channels that have that driver assigned
  • updated chooseChannel function to use createChooseFn

@rossiam rossiam requested a review from a team June 16, 2025 14:55
@changeset-bot

changeset-bot Bot commented Jun 16, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 59a3ca2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@rossiam rossiam force-pushed the yargs-edge-channels-unassign branch from b8efe22 to 9088df0 Compare June 16, 2025 15:26
@rossiam rossiam changed the title refactor: convert edge:channels:unassign command to yargs refactor: convert edge:channels:(un)?assign command to yargs Jun 16, 2025
'assign the specified driver to the specified channel',
],
])
.epilog(apiDocsURL('createDriverChannel'))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there also be an example using driver-version?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't include one because that is rarely, if ever, needed.

Comment thread src/commands/edge/channels/assign.ts Outdated

await command.client.channels.assignDriver(channelId, driverId, driverVersion)

console.log(`${driverId}${argv.version ? ` (version ${argv.version})` : ''} assigned to channel ${channelId}`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this want to be driverVersion rather than argv.version? Also, if the latter, shouldn't it be argv.driverVersion?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good catch. I actually removed the ternary and just used the local variable driverVersion since it seems silly to me now to leave out the version used just because the user didn't specify it. (I don't know what I was thinking when I originally wrote that.)

}))
return allChannels.filter(channel => channelsToKeep.includes(channel.channelId))
}
return allChannels

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it compile a list of channelIds and then filter the channel list by that rather than compile a list of channels?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that didn't occur to me. I've changed the capture list to a list of channels and removed the filter.

@rossiam rossiam force-pushed the yargs-edge-channels-unassign branch from acbb01e to 59a3ca2 Compare June 17, 2025 13:02
@rossiam rossiam merged commit 13e810f into SmartThingsCommunity:yargs Jun 17, 2025
4 checks passed
@rossiam rossiam deleted the yargs-edge-channels-unassign branch June 17, 2025 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants