-
Notifications
You must be signed in to change notification settings - Fork 23
/
removecurator.go
54 lines (46 loc) · 1.38 KB
/
removecurator.go
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
package cmd
import (
"log"
"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/spf13/cobra"
)
var removeCuratorCmd = &cobra.Command{
Use: "removecurator",
Short: "Removes a curator from an allocation",
Long: "Removes a curator from an allocation",
Args: cobra.MinimumNArgs(0),
Run: func(cmd *cobra.Command, args []string) {
var err error
var flags = cmd.Flags()
if flags.Changed("allocation") == false {
log.Fatal("Error: allocation flag is missing")
}
allocationID, err := flags.GetString("allocation")
if err != nil {
log.Fatal("invalid 'allocation_id' flag: ", err)
}
if flags.Changed("curator") == false {
log.Fatal("Error: curator flag is missing")
}
curatorID, err := flags.GetString("curator")
if err != nil {
log.Fatal("invalid 'curator_id' flag: ", err)
}
_, err = sdk.RemoveCurator(curatorID, allocationID)
if err != nil {
log.Fatal("Error adding curator:", err)
}
log.Print(curatorID + " removed " + curatorID + " as a curator to allocation " + allocationID)
},
}
func init() {
rootCmd.AddCommand(removeCuratorCmd)
removeCuratorCmd.PersistentFlags().
String("curator", "",
"the curator to remove from allocation")
removeCuratorCmd.PersistentFlags().
String("allocation", "",
"allocation from which the curator is to be removed")
removeCuratorCmd.MarkFlagRequired("curator")
removeCuratorCmd.MarkFlagRequired("allocation")
}