2016-10-16 23:57:56 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2016. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2016-11-15 17:44:16 +04:00
|
|
|
open Client_config
|
|
|
|
|
2016-10-16 23:57:56 +04:00
|
|
|
let unique = ref false
|
|
|
|
let unique_arg =
|
|
|
|
"-unique",
|
|
|
|
Arg.Set unique,
|
|
|
|
"Fail when there is more than one possible completion."
|
|
|
|
|
|
|
|
let commands () = Cli_entries.[
|
|
|
|
command
|
|
|
|
~desc: "Lookup for the possible completion of a \
|
2017-02-19 21:22:32 +04:00
|
|
|
given prefix of Base58Check-encoded hash. This actually \
|
2016-11-15 17:44:16 +04:00
|
|
|
works only for blocks, operations, public key and contract \
|
|
|
|
identifiers."
|
2016-10-16 23:57:56 +04:00
|
|
|
~args: [unique_arg]
|
2016-12-03 16:05:02 +04:00
|
|
|
(prefixes [ "complete" ] @@
|
|
|
|
string
|
|
|
|
~name: "prefix"
|
2017-02-19 21:22:32 +04:00
|
|
|
~desc: "the prefix of the Base58Check-encoded hash to be completed" @@
|
2016-12-03 16:05:02 +04:00
|
|
|
stop)
|
|
|
|
(fun prefix cctxt ->
|
|
|
|
Client_node_rpcs.complete cctxt ~block:(block ()) prefix >>= fun completions ->
|
2016-10-16 23:57:56 +04:00
|
|
|
match completions with
|
|
|
|
| [] -> Pervasives.exit 3
|
|
|
|
| _ :: _ :: _ when !unique -> Pervasives.exit 3
|
|
|
|
| completions ->
|
|
|
|
List.iter print_endline completions ;
|
|
|
|
Lwt.return_unit)
|
2016-12-03 16:05:02 +04:00
|
|
|
]
|