-
Notifications
You must be signed in to change notification settings - Fork 9
/
txfeed.go
90 lines (76 loc) · 2.19 KB
/
txfeed.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package commands
import (
"os"
"github.com/spf13/cobra"
jww "github.com/spf13/jwalterweatherman"
"github.com/vapor/util"
)
var createTransactionFeedCmd = &cobra.Command{
Use: "create-transaction-feed <alias> <filter>",
Short: "Create a transaction feed filter",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
var in txFeed
in.Alias = args[0]
in.Filter = args[1]
_, exitCode := util.ClientCall("/create-transaction-feed", &in)
if exitCode != util.Success {
os.Exit(exitCode)
}
jww.FEEDBACK.Println("Successfully created transaction feed")
},
}
var listTransactionFeedsCmd = &cobra.Command{
Use: "list-transaction-feeds",
Short: "list all of transaction feeds",
Args: cobra.NoArgs,
Run: func(cmd *cobra.Command, args []string) {
data, exitCode := util.ClientCall("/list-transaction-feeds")
if exitCode != util.Success {
os.Exit(exitCode)
}
printJSONList(data)
},
}
var deleteTransactionFeedCmd = &cobra.Command{
Use: "delete-transaction-feed <alias>",
Short: "Delete a transaction feed filter",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var in txFeed
in.Alias = args[0]
_, exitCode := util.ClientCall("/delete-transaction-feed", &in)
if exitCode != util.Success {
os.Exit(exitCode)
}
jww.FEEDBACK.Println("Successfully deleted transaction feed")
},
}
var getTransactionFeedCmd = &cobra.Command{
Use: "get-transaction-feed <alias>",
Short: "get a transaction feed by alias",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
var in txFeed
in.Alias = args[0]
data, exitCode := util.ClientCall("/get-transaction-feed", &in)
if exitCode != util.Success {
os.Exit(exitCode)
}
printJSON(data)
},
}
var updateTransactionFeedCmd = &cobra.Command{
Use: "update-transaction-feed <alias> <fiter>",
Short: "Update transaction feed",
Args: cobra.ExactArgs(2),
Run: func(cmd *cobra.Command, args []string) {
var in txFeed
in.Alias = args[0]
in.Filter = args[1]
if _, exitCode := util.ClientCall("/update-transaction-feed", &in); exitCode != util.Success {
os.Exit(exitCode)
}
jww.FEEDBACK.Println("Successfully updated transaction feed")
},
}