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. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2018-02-14 18:20:03 +04:00
|
|
|
open Client_context
|
2018-02-11 22:17:40 +04:00
|
|
|
|
2018-02-13 20:56:47 +04:00
|
|
|
type command = full_context Cli_entries.command
|
2016-12-03 16:05:02 +04:00
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
exception Version_not_found
|
|
|
|
|
2017-02-24 20:17:53 +04:00
|
|
|
let versions = Protocol_hash.Table.create 7
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let get_versions () =
|
2017-02-24 20:17:53 +04:00
|
|
|
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 =
|
2017-02-24 20:17:53 +04:00
|
|
|
try Protocol_hash.Table.find versions name
|
2016-09-08 21:13:10 +04:00
|
|
|
with Not_found -> [] in
|
2017-11-27 02:17:25 +04:00
|
|
|
Protocol_hash.Table.replace versions name (commands @ previous)
|
2016-09-08 21:13:10 +04:00
|
|
|
|
|
|
|
let commands_for_version version =
|
2017-02-24 20:17:53 +04:00
|
|
|
try Protocol_hash.Table.find versions version
|
2016-09-08 21:13:10 +04:00
|
|
|
with Not_found -> raise Version_not_found
|