ligo/src/lib_client_commands/client_commands.ml

35 lines
1.3 KiB
OCaml
Raw Normal View History

2016-09-08 21:13:10 +04:00
(**************************************************************************)
(* *)
2018-02-06 00:17:03 +04:00
(* Copyright (c) 2014 - 2018. *)
2016-09-08 21:13:10 +04:00
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
(* *)
(* All rights reserved. No warranty, explicit or implicit, provided. *)
(* *)
(**************************************************************************)
open Client_context
2018-04-03 13:39:09 +04:00
type command = full Clic.command
type network = [ `Betanet | `Alphanet | `Zeronet | `Sandbox ]
2016-09-08 21:13:10 +04:00
exception Version_not_found
let versions = Protocol_hash.Table.create 7
2016-09-08 21:13:10 +04:00
let get_versions () =
Protocol_hash.Table.fold
2016-09-08 21:13:10 +04:00
(fun k c acc -> (k, c) :: acc)
versions
[]
let register name commands =
let previous =
try Protocol_hash.Table.find versions name
with Not_found -> (fun (_network : network option) -> ([] : command list)) in
Protocol_hash.Table.replace versions name
(fun (network : network option) -> (commands network @ previous network))
2016-09-08 21:13:10 +04:00
let commands_for_version version =
try Protocol_hash.Table.find versions version
2016-09-08 21:13:10 +04:00
with Not_found -> raise Version_not_found