Client: add rpc call ... with '{json}'
This commit is contained in:
parent
9a0ac6b837
commit
0a3ad7de53
@ -309,12 +309,26 @@ let call url cctxt =
|
|||||||
cctxt.error "%s" msg
|
cctxt.error "%s" msg
|
||||||
| Ok json ->
|
| Ok json ->
|
||||||
Client_node_rpcs.get_json cctxt args json >>= fun json ->
|
Client_node_rpcs.get_json cctxt args json >>= fun json ->
|
||||||
cctxt.message "Output:\n%s\n%!" (Data_encoding_ezjsonm.to_string json)
|
cctxt.message
|
||||||
|
"Output:\n%s\n%!" (Data_encoding_ezjsonm.to_string json)
|
||||||
end
|
end
|
||||||
| _ ->
|
| _ ->
|
||||||
cctxt.message
|
cctxt.message
|
||||||
"No service found at this URL (but this is a valid prefix)\n%!"
|
"No service found at this URL (but this is a valid prefix)\n%!"
|
||||||
|
|
||||||
|
let call_with_json url json (cctxt: Client_commands.context) =
|
||||||
|
let args = Utils.split '/' url in
|
||||||
|
match Data_encoding_ezjsonm.from_string json with
|
||||||
|
| Error err ->
|
||||||
|
cctxt.error
|
||||||
|
"Failed to parse the proviede json: %s\n%!"
|
||||||
|
err
|
||||||
|
| Ok json ->
|
||||||
|
let open RPC.Description in
|
||||||
|
Client_node_rpcs.get_json cctxt args json >>= fun json ->
|
||||||
|
cctxt.message
|
||||||
|
"Output:\n%s\n%!" (Data_encoding_ezjsonm.to_string json)
|
||||||
|
|
||||||
let group =
|
let group =
|
||||||
{ Cli_entries.name = "rpc" ;
|
{ Cli_entries.name = "rpc" ;
|
||||||
title = "Commands for the low level RPC layer" }
|
title = "Commands for the low level RPC layer" }
|
||||||
@ -337,5 +351,9 @@ let commands = [
|
|||||||
schema ;
|
schema ;
|
||||||
command ~group ~desc: "call an RPC (low level command for advanced users)"
|
command ~group ~desc: "call an RPC (low level command for advanced users)"
|
||||||
(prefixes [ "rpc" ; "call" ] @@ string ~name: "url" ~desc: "the RPC's URL" @@ stop)
|
(prefixes [ "rpc" ; "call" ] @@ string ~name: "url" ~desc: "the RPC's URL" @@ stop)
|
||||||
call
|
call ;
|
||||||
|
command ~group ~desc: "call an RPC (low level command for advanced users)"
|
||||||
|
(prefixes [ "rpc" ; "call" ] @@ string ~name: "url" ~desc: "the RPC's URL"
|
||||||
|
@@ prefix "with" @@ string ~name:"" ~desc:"" @@ stop)
|
||||||
|
call_with_json
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user