Client: use contextual completion

This commit is contained in:
Grégoire Henry 2016-11-15 14:44:16 +01:00
parent d61220f4f9
commit 719b54ac1d
3 changed files with 14 additions and 5 deletions

View File

@ -7,6 +7,8 @@
(* *) (* *)
(**************************************************************************) (**************************************************************************)
open Client_config
let () = let () =
let open Cli_entries in let open Cli_entries in
register_group "helpers" "Various helpers" register_group "helpers" "Various helpers"
@ -21,11 +23,12 @@ let commands () = Cli_entries.[
command command
~desc: "Lookup for the possible completion of a \ ~desc: "Lookup for the possible completion of a \
given prefix of Base48Check-encoded hash. This actually \ given prefix of Base48Check-encoded hash. This actually \
works only for blocks and operations." works only for blocks, operations, public key and contract \
identifiers."
~args: [unique_arg] ~args: [unique_arg]
(prefixes [ "complete" ] @@ string "prefix" "the prefix of the Base48Check-encoded hash to be completed" @@ stop) (prefixes [ "complete" ] @@ string "prefix" "the prefix of the Base48Check-encoded hash to be completed" @@ stop)
(fun prefix () -> (fun prefix () ->
Client_node_rpcs.complete prefix >>= fun completions -> Client_node_rpcs.complete ~block:(block ()) prefix >>= fun completions ->
match completions with match completions with
| [] -> Pervasives.exit 3 | [] -> Pervasives.exit 3
| _ :: _ :: _ when !unique -> Pervasives.exit 3 | _ :: _ :: _ when !unique -> Pervasives.exit 3

View File

@ -150,8 +150,12 @@ let inject_operation ?(wait = true) ?force operation =
call_service0 Services.inject_operation (operation, wait, force) call_service0 Services.inject_operation (operation, wait, force)
let inject_protocol ?(wait = true) ?force protocol = let inject_protocol ?(wait = true) ?force protocol =
call_service0 Services.inject_protocol (protocol, wait, force) call_service0 Services.inject_protocol (protocol, wait, force)
let complete prefix = let complete ?block prefix =
match block with
| None ->
call_service1 Services.complete prefix () call_service1 Services.complete prefix ()
| Some block ->
call_service2 Services.Blocks.complete block prefix ()
let describe ?recurse path = let describe ?recurse path =
let prefix, arg = RPC.forge_request Services.describe () recurse in let prefix, arg = RPC.forge_request Services.describe () recurse in
get_json (prefix @ path) arg >>= get_json (prefix @ path) arg >>=
@ -198,6 +202,8 @@ module Blocks = struct
call_service1 Services.Blocks.pending_operations block () call_service1 Services.Blocks.pending_operations block ()
let info ?(operations = false) h = let info ?(operations = false) h =
call_service1 Services.Blocks.info h operations call_service1 Services.Blocks.info h operations
let complete block prefix =
call_service2 Services.Blocks.complete block prefix ()
let list ?operations ?length ?heads ?delay ?min_date ?min_heads () = let list ?operations ?length ?heads ?delay ?min_date ?min_heads () =
call_service0 Services.Blocks.list call_service0 Services.Blocks.list
{ operations; length ; heads ; monitor = Some false ; delay ; { operations; length ; heads ; monitor = Some false ; delay ;

View File

@ -104,7 +104,7 @@ module Protocols : sig
(Protocol_hash.t * Store.protocol option) list Lwt.t (Protocol_hash.t * Store.protocol option) list Lwt.t
end end
val complete: string -> string list Lwt.t val complete: ?block:Blocks.block -> string -> string list Lwt.t
val describe: ?recurse:bool -> string list -> RPC.Description.directory_descr Lwt.t val describe: ?recurse:bool -> string list -> RPC.Description.directory_descr Lwt.t