Client: do not fail when the protocol is unknown...

This commit is contained in:
Grégoire Henry 2017-03-13 17:40:51 +01:00 committed by Benjamin Canou
parent 7ba73a5955
commit 2d828060d5

View File

@ -9,7 +9,7 @@
(* Tezos Command line interface - Main Program *) (* Tezos Command line interface - Main Program *)
open Lwt open Lwt.Infix
let cctxt = let cctxt =
let startup = let startup =
@ -36,36 +36,33 @@ let cctxt =
let main () = let main () =
Random.self_init () ; Random.self_init () ;
Sodium.Random.stir () ; Sodium.Random.stir () ;
catch Lwt.catch begin fun () ->
(fun () ->
Client_config.preparse_args Sys.argv cctxt >>= fun block -> Client_config.preparse_args Sys.argv cctxt >>= fun block ->
Lwt.catch Lwt.catch begin fun () ->
(fun () -> Client_node_rpcs.Blocks.protocol cctxt block >>= fun version ->
Client_node_rpcs.Blocks.protocol cctxt block) Lwt.return (Some version, Client_commands.commands_for_version version)
(fun exn -> end begin fun exn ->
cctxt.warning cctxt.warning
"Error trying to acquire the protocol version from the node: %s." "Failed to acquire the protocol version from the node: %s."
(match exn with (match exn with
| Failure msg -> msg | Failure msg -> msg
| exn -> Printexc.to_string exn) >>= fun () -> | exn -> Printexc.to_string exn) >>= fun () ->
cctxt.warning Lwt.return (None, [])
"Using the default protocol version." >>= fun () -> end >>= fun (version, commands_for_version) ->
Lwt.return Client_alpha.Client_proto_main.protocol)
>>= fun version ->
let commands = let commands =
Client_generic_rpcs.commands @ Client_generic_rpcs.commands @
Client_network.commands () @ Client_network.commands () @
Client_keys.commands () @ Client_keys.commands () @
Client_protocols.commands () @ Client_protocols.commands () @
Client_helpers.commands () @ Client_helpers.commands () @
Client_commands.commands_for_version version in commands_for_version in
Client_config.parse_args ~version Client_config.parse_args ?version
(Cli_entries.usage ~commands) (Cli_entries.usage ~commands)
(Cli_entries.inline_dispatch commands) (Cli_entries.inline_dispatch commands)
Sys.argv cctxt >>= fun command -> Sys.argv cctxt >>= fun command ->
command cctxt >>= fun () -> command cctxt >>= fun () ->
Lwt.return 0) Lwt.return 0
(function end begin function
| Arg.Help help -> | Arg.Help help ->
Format.printf "%s%!" help ; Format.printf "%s%!" help ;
Lwt.return 0 Lwt.return 0
@ -90,7 +87,8 @@ let main () =
| exn -> | exn ->
Format.printf "Fatal internal error: %s\n%!" Format.printf "Fatal internal error: %s\n%!"
(Printexc.to_string exn) ; (Printexc.to_string exn) ;
Lwt.return 1) Lwt.return 1
end
(* Where all the user friendliness starts *) (* Where all the user friendliness starts *)
let () = Pervasives.exit (Lwt_main.run (main ())) let () = Pervasives.exit (Lwt_main.run (main ()))