2016-10-16 23:57:56 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2016-10-16 23:57:56 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2017-04-05 01:35:41 +04:00
|
|
|
open Client_commands
|
2016-11-15 17:44:16 +04:00
|
|
|
|
2017-09-19 13:31:35 +04:00
|
|
|
let unique_switch =
|
|
|
|
Cli_entries.switch
|
|
|
|
~parameter:"-unique"
|
|
|
|
~doc:"Fail when there is more than one possible completion."
|
2016-10-16 23:57:56 +04:00
|
|
|
|
|
|
|
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."
|
2017-09-19 13:31:35 +04:00
|
|
|
(args1 unique_switch)
|
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)
|
2017-09-19 13:31:35 +04:00
|
|
|
(fun unique prefix cctxt ->
|
2017-04-05 01:35:41 +04:00
|
|
|
Client_node_rpcs.complete
|
|
|
|
cctxt.rpc_config ~block:cctxt.config.block prefix >>=? fun completions ->
|
2016-10-16 23:57:56 +04:00
|
|
|
match completions with
|
|
|
|
| [] -> Pervasives.exit 3
|
2017-09-19 13:31:35 +04:00
|
|
|
| _ :: _ :: _ when unique -> Pervasives.exit 3
|
2016-10-16 23:57:56 +04:00
|
|
|
| completions ->
|
|
|
|
List.iter print_endline completions ;
|
2017-04-05 01:35:41 +04:00
|
|
|
return ()) ;
|
2017-02-28 03:48:22 +04:00
|
|
|
command
|
|
|
|
~desc: "Wait for the node to be bootstrapped."
|
2017-09-19 13:31:35 +04:00
|
|
|
no_options
|
2017-02-28 03:48:22 +04:00
|
|
|
(prefixes [ "bootstrapped" ] @@
|
|
|
|
stop)
|
2017-09-19 13:31:35 +04:00
|
|
|
(fun () cctxt ->
|
2017-04-05 01:35:41 +04:00
|
|
|
Client_node_rpcs.bootstrapped cctxt.rpc_config >>=? fun stream ->
|
|
|
|
Lwt_stream.iter_s (function
|
|
|
|
| Ok (hash, time) ->
|
|
|
|
cctxt.message "Current head: %a (%a)"
|
|
|
|
Block_hash.pp_short hash
|
|
|
|
Time.pp_hum time
|
|
|
|
| Error err ->
|
|
|
|
cctxt.error "Error: %a"
|
|
|
|
pp_print_error err
|
2017-02-28 03:48:22 +04:00
|
|
|
) stream >>= fun () ->
|
2017-04-05 01:35:41 +04:00
|
|
|
cctxt.answer "Bootstrapped." >>= fun () ->
|
|
|
|
return ()
|
2017-11-13 19:34:00 +04:00
|
|
|
)
|
2016-12-03 16:05:02 +04:00
|
|
|
]
|