ligo/src/lib_client_commands/client_helpers_commands.ml

53 lines
2.0 KiB
OCaml
Raw Normal View History

2016-10-16 23:57:56 +04:00
(**************************************************************************)
(* *)
2018-02-06 00:17:03 +04:00
(* Copyright (c) 2014 - 2018. *)
2016-10-16 23:57:56 +04:00
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
let unique_switch =
2018-04-03 13:39:09 +04:00
Clic.switch
~long:"unique"
~short:'u'
~doc:"Fail when there is more than one possible completion."
()
2016-10-16 23:57:56 +04:00
2018-04-03 13:39:09 +04:00
let commands () = Clic.[
2016-10-16 23:57:56 +04:00
command
~desc: "Autocomplete a prefix of Base58Check-encoded hash.\n\
This actually works only for blocks, operations, public \
key and contract identifiers."
(args1 unique_switch)
(prefixes [ "complete" ] @@
string
~name: "prefix"
~desc: "the prefix of the hash to complete" @@
stop)
(fun unique prefix (cctxt : #Client_context.full) ->
Shell_services.complete
2017-11-07 20:38:11 +04:00
cctxt ~block:cctxt#block prefix >>=? fun completions ->
2016-10-16 23:57:56 +04:00
match completions with
| [] -> Pervasives.exit 3
| _ :: _ :: _ when unique -> Pervasives.exit 3
2016-10-16 23:57:56 +04:00
| completions ->
List.iter print_endline completions ;
return ()) ;
command
~desc: "Wait for the node to be bootstrapped."
no_options
(prefixes [ "bootstrapped" ] @@
stop)
(fun () (cctxt : #Client_context.full) ->
Shell_services.bootstrapped cctxt >>=? fun (stream, _) ->
Lwt_stream.iter_s
(fun (hash, time) ->
cctxt#message "Current head: %a (%a)"
Block_hash.pp_short hash
Time.pp_hum time) stream >>= fun () ->
2017-11-07 20:38:11 +04:00
cctxt#answer "Bootstrapped." >>= fun () ->
return ()
)
]