myChannels.ts 939 B

12345678910111213141516171819202122232425
  1. import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
  2. import { ChannelEntity } from 'cd-schemas/types/entities/ChannelEntity'
  3. import { displayTable } from '../../helpers/display'
  4. import chalk from 'chalk'
  5. export default class MyChannelsCommand extends ContentDirectoryCommandBase {
  6. static description = "Show the list of channels associated with current account's membership."
  7. async run() {
  8. const memberId = await this.getRequiredMemberId()
  9. const props: (keyof ChannelEntity)[] = ['title', 'isPublic']
  10. const list = await this.createEntityList('Channel', props, [], memberId)
  11. if (list.length) {
  12. displayTable(list, 3)
  13. this.log(
  14. `\nTIP: Use ${chalk.bold('content-directory:entity ID')} command to see more details about given channel`
  15. )
  16. } else {
  17. this.log(`No channels created yet! Create a channel with ${chalk.bold('media:createChannel')}`)
  18. }
  19. }
  20. }