Skip to content

Commit 5cb073f

Browse files
author
rogerzr
committed
Added pushJ command
1 parent 309c691 commit 5cb073f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

interface.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ var (
3434
pushMethod = push.Arg("method", "Method to call").Required().String()
3535
pushParams = push.Arg("params", "parameters").StringMap()
3636

37+
pushJ = app.Command("pushj", "Execute a task.push rpc call on Nexus. Params is a json dict like: { 'param': value }")
38+
pushJMethod = pushJ.Arg("method", "Method to call").Required().String()
39+
pushJParams = pushJ.Arg("json {param:value,...}", "{'param': 3, 'other': {'val': true}}").Required().String()
40+
3741
pull = app.Command("pull", "Execute a task.pull rpc call on Nexus")
3842
pullMethod = pull.Arg("prefix", "Method to call").Required().String()
3943

main.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,26 @@ func execCmd(nc *nexus.NexusConn, parsed string) {
134134
}
135135
}
136136

137+
case pushJ.FullCommand():
138+
var params map[string]interface{}
139+
if json.Unmarshal([]byte(*pushJParams), &params) != nil {
140+
log.Println("Error parsing params json:", *pushJParams)
141+
return
142+
}
143+
144+
if ret, err := nc.TaskPush(*pushJMethod, params, time.Second*time.Duration(*timeout)); err != nil {
145+
log.Println("Error:", err)
146+
return
147+
} else {
148+
b, _ := json.MarshalIndent(ret, "", " ")
149+
log.Println("Result:")
150+
if s, err := strconv.Unquote(string(b)); err == nil {
151+
fmt.Println(s)
152+
} else {
153+
fmt.Println(string(b))
154+
}
155+
}
156+
137157
case pull.FullCommand():
138158
log.Println("Pulling", *pullMethod)
139159
ret, err := nc.TaskPull(*pullMethod, time.Second*time.Duration(*timeout))

0 commit comments

Comments
 (0)