-
Notifications
You must be signed in to change notification settings - Fork 115
/
setCuratorGroupStatus.ts
66 lines (58 loc) · 1.75 KB
/
setCuratorGroupStatus.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
import chalk from 'chalk'
import ExitCodes from '../../ExitCodes'
export default class SetCuratorGroupStatusCommand extends ContentDirectoryCommandBase {
static description = 'Set Curator Group status (Active/Inactive).'
static args = [
{
name: 'id',
required: false,
description: 'ID of the Curator Group',
},
{
name: 'status',
required: false,
description: 'New status of the group (1 - active, 0 - inactive)',
},
]
static flags = {
...ContentDirectoryCommandBase.flags,
}
async run(): Promise<void> {
const lead = await this.getRequiredLeadContext()
let { id, status } = this.parse(SetCuratorGroupStatusCommand).args
if (id === undefined) {
id = await this.promptForCuratorGroup()
} else {
await this.getCuratorGroup(id)
}
if (status === undefined) {
status = await this.simplePrompt({
type: 'list',
message: 'Select new status',
choices: [
{ name: 'Active', value: true },
{ name: 'Inactive', value: false },
],
})
} else {
if (status !== '0' && status !== '1') {
this.error('Invalid status provided. Use "1" for Active and "0" for Inactive.', {
exit: ExitCodes.InvalidInput,
})
}
status = !!parseInt(status)
}
await this.sendAndFollowNamedTx(await this.getDecodedPair(lead.roleAccount), 'content', 'setCuratorGroupStatus', [
id,
status,
])
console.log(
chalk.green(
`Curator Group ${chalk.magentaBright(id)} status successfully changed to: ${chalk.magentaBright(
status ? 'Active' : 'Inactive'
)}!`
)
)
}
}