From 719b54ac1db36f7b079190ed0f52a4c27ee38c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Tue, 15 Nov 2016 14:44:16 +0100 Subject: [PATCH] Client: use contextual completion --- src/client/client_helpers.ml | 7 +++++-- src/client/client_node_rpcs.ml | 10 ++++++++-- src/client/client_node_rpcs.mli | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/client/client_helpers.ml b/src/client/client_helpers.ml index e5fa85b8d..4555be6ee 100644 --- a/src/client/client_helpers.ml +++ b/src/client/client_helpers.ml @@ -7,6 +7,8 @@ (* *) (**************************************************************************) +open Client_config + let () = let open Cli_entries in register_group "helpers" "Various helpers" @@ -21,11 +23,12 @@ let commands () = Cli_entries.[ command ~desc: "Lookup for the possible completion of a \ 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] (prefixes [ "complete" ] @@ string "prefix" "the prefix of the Base48Check-encoded hash to be completed" @@ stop) (fun prefix () -> - Client_node_rpcs.complete prefix >>= fun completions -> + Client_node_rpcs.complete ~block:(block ()) prefix >>= fun completions -> match completions with | [] -> Pervasives.exit 3 | _ :: _ :: _ when !unique -> Pervasives.exit 3 diff --git a/src/client/client_node_rpcs.ml b/src/client/client_node_rpcs.ml index f897ebfd4..247195539 100644 --- a/src/client/client_node_rpcs.ml +++ b/src/client/client_node_rpcs.ml @@ -150,8 +150,12 @@ let inject_operation ?(wait = true) ?force operation = call_service0 Services.inject_operation (operation, wait, force) let inject_protocol ?(wait = true) ?force protocol = call_service0 Services.inject_protocol (protocol, wait, force) -let complete prefix = - call_service1 Services.complete prefix () +let complete ?block prefix = + match block with + | None -> + call_service1 Services.complete prefix () + | Some block -> + call_service2 Services.Blocks.complete block prefix () let describe ?recurse path = let prefix, arg = RPC.forge_request Services.describe () recurse in get_json (prefix @ path) arg >>= @@ -198,6 +202,8 @@ module Blocks = struct call_service1 Services.Blocks.pending_operations block () let info ?(operations = false) h = 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 () = call_service0 Services.Blocks.list { operations; length ; heads ; monitor = Some false ; delay ; diff --git a/src/client/client_node_rpcs.mli b/src/client/client_node_rpcs.mli index 3fe7e5fd6..8944348fe 100644 --- a/src/client/client_node_rpcs.mli +++ b/src/client/client_node_rpcs.mli @@ -104,7 +104,7 @@ module Protocols : sig (Protocol_hash.t * Store.protocol option) list Lwt.t 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