removeCuratorGroup.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
  2. import chalk from 'chalk'
  3. import ExitCodes from '../../ExitCodes'
  4. export default class AddCuratorGroupCommand extends ContentDirectoryCommandBase {
  5. static description = 'Remove existing Curator Group.'
  6. static args = [
  7. {
  8. name: 'id',
  9. required: false,
  10. description: 'ID of the Curator Group to remove',
  11. },
  12. ]
  13. async run() {
  14. const account = await this.getRequiredSelectedAccount()
  15. await this.requireLead()
  16. let { id } = this.parse(AddCuratorGroupCommand).args
  17. if (id === undefined) {
  18. id = await this.promptForCuratorGroup('Select Curator Group to remove')
  19. }
  20. const group = await this.getCuratorGroup(id)
  21. if (group.number_of_classes_maintained.toNumber() > 0) {
  22. this.error('Cannot remove a group which has some maintained classes!', { exit: ExitCodes.InvalidInput })
  23. }
  24. await this.requestAccountDecoding(account)
  25. await this.sendAndFollowNamedTx(account, 'contentDirectory', 'removeCuratorGroup', [id])
  26. console.log(chalk.green(`Curator Group ${chalk.white(id)} succesfully removed!`))
  27. }
  28. }