7 "github.com/spf13/cobra"
8 jww "github.com/spf13/jwalterweatherman"
12 Alias string `json:"alias"`
13 Filter string `json:"filter,omitempty"`
16 type respArrayTxFeed struct {
17 Status string `json:"status,omitempty"`
18 Msg string `json:"msg,omitempty"`
19 Data []*txFeed `json:"data,omitempty"`
22 type respTxFeed struct {
23 Status string `json:"status,omitempty"`
24 Msg string `json:"msg,omitempty"`
25 Data txFeed `json:"data,omitempty"`
28 var createTransactionFeedCmd = &cobra.Command{
29 Use: "create-transaction-feed",
30 Short: "Create a transaction feed filter",
31 Run: func(cmd *cobra.Command, args []string) {
33 jww.ERROR.Println("create-transaction-feed needs 2 args")
41 var response interface{}
43 client := mustRPCClient()
44 client.Call(context.Background(), "/create-transaction-feed", &in, &response)
48 if err := parseresp(response, &rawresp); err != nil {
49 jww.ERROR.Println("parse response error")
53 if rawresp.Status == "success" {
54 jww.FEEDBACK.Printf("%v\n", rawresp.Data)
58 if rawresp.Status == "error" {
59 jww.ERROR.Println(rawresp.Msg)
65 var listTransactionFeedsCmd = &cobra.Command{
66 Use: "list-transaction-feeds",
67 Short: "list all of transaction feeds",
68 Run: func(cmd *cobra.Command, args []string) {
70 jww.ERROR.Println("list-transaction-feeds takes no args")
75 var response interface{}
77 client := mustRPCClient()
78 client.Call(context.Background(), "/list-transaction-feeds", in, &response)
80 var rawresp respArrayTxFeed
81 if err := parseresp(response, &rawresp); err != nil {
82 jww.ERROR.Println("parse response error")
86 if rawresp.Status == "success" {
87 for i, v := range rawresp.Data {
88 fmt.Println(i, v.Alias, v.Filter)
93 if rawresp.Status == "error" {
94 jww.ERROR.Println(rawresp.Msg)
100 var deleteTransactionFeedCmd = &cobra.Command{
101 Use: "delete-transaction-feed",
102 Short: "Delete a transaction feed filter",
103 Run: func(cmd *cobra.Command, args []string) {
105 jww.ERROR.Println("delete-transaction-feed needs 1 args")
112 var response interface{}
114 client := mustRPCClient()
115 client.Call(context.Background(), "/delete-transaction-feed", &in, &response)
118 if err := parseresp(response, &rawresp); err != nil {
119 jww.ERROR.Println("parse response error")
123 if rawresp.Status == "success" {
124 jww.FEEDBACK.Printf("%v\n", rawresp.Data)
128 if rawresp.Status == "error" {
129 jww.ERROR.Println(rawresp.Msg)
135 var getTransactionFeedCmd = &cobra.Command{
136 Use: "get-transaction-feed",
137 Short: "get a transaction feed by alias",
138 Run: func(cmd *cobra.Command, args []string) {
140 jww.ERROR.Println("get-transaction-feed needs 1 args")
146 var response interface{}
148 client := mustRPCClient()
149 client.Call(context.Background(), "/get-transaction-feed", &in, &response)
151 var rawresp respTxFeed
153 if err := parseresp(response, &rawresp); err != nil {
154 jww.ERROR.Println("parse response error")
158 if rawresp.Status == "success" {
159 fmt.Println(rawresp.Data)
163 if rawresp.Status == "error" {
164 jww.ERROR.Println(rawresp.Msg)
170 var updateTransactionFeedCmd = &cobra.Command{
171 Use: "update-transaction-feed",
172 Short: "Update transaction feed",
173 Run: func(cmd *cobra.Command, args []string) {
175 jww.ERROR.Println("update-transaction-feed needs 2 args")
183 var response interface{}
185 client := mustRPCClient()
186 client.Call(context.Background(), "/update-transaction-feed", &in, &response)
189 if err := parseresp(response, &rawresp); err != nil {
190 jww.ERROR.Println("parse response error")
194 if rawresp.Status == "success" {
195 jww.FEEDBACK.Printf("%v\n", rawresp.Data)
199 if rawresp.Status == "error" {
200 jww.ERROR.Println(rawresp.Msg)