diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bb976a954..58b6b85ac 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -279,36 +279,36 @@ opam:08:tezos-micheline: variables: package: tezos-micheline -opam:09:tezos-protocol-environment-sigs: - <<: *opam_definition - variables: - package: tezos-protocol-environment-sigs - -opam:10:tezos-rpc: +opam:09:tezos-rpc: <<: *opam_definition variables: package: tezos-rpc -opam:11:tezos-base: +opam:10:tezos-base: <<: *opam_definition variables: package: tezos-base -opam:12:pbkdf: +opam:11:pbkdf: <<: *opam_definition variables: package: pbkdf -opam:13:ocplib-resto-cohttp: +opam:12:ocplib-resto-cohttp: <<: *opam_definition variables: package: ocplib-resto-cohttp -opam:14:irmin-leveldb: +opam:13:irmin-leveldb: <<: *opam_definition variables: package: irmin-leveldb +opam:14:tezos-protocol-environment-sigs: + <<: *opam_definition + variables: + package: tezos-protocol-environment-sigs + opam:15:tezos-stdlib-unix: <<: *opam_definition variables: @@ -364,105 +364,110 @@ opam:25:tezos-client-commands: variables: package: tezos-client-commands -opam:26:tezos-baking-alpha: +opam:26:tezos-protocol-environment-shell: + <<: *opam_definition + variables: + package: tezos-protocol-environment-shell + +opam:27:tezos-baking-alpha: <<: *opam_definition variables: package: tezos-baking-alpha -opam:27:tezos-protocol-genesis: +opam:28:tezos-protocol-genesis: <<: *opam_definition variables: package: tezos-protocol-genesis -opam:28:tezos-protocol-updater: - <<: *opam_definition - variables: - package: tezos-protocol-updater - -opam:29:tezos-p2p: - <<: *opam_definition - variables: - package: tezos-p2p - -opam:30:ocplib-resto-json: +opam:29:ocplib-resto-json: <<: *opam_definition variables: package: ocplib-resto-json -opam:31:tezos-baking-alpha-commands: +opam:30:tezos-protocol-updater: + <<: *opam_definition + variables: + package: tezos-protocol-updater + +opam:31:tezos-p2p: + <<: *opam_definition + variables: + package: tezos-p2p + +opam:32:tezos-baking-alpha-commands: <<: *opam_definition variables: package: tezos-baking-alpha-commands -opam:32:tezos-client-alpha-commands: +opam:33:tezos-client-alpha-commands: <<: *opam_definition variables: package: tezos-client-alpha-commands -opam:33:tezos-client-base-unix: +opam:34:tezos-client-base-unix: <<: *opam_definition variables: package: tezos-client-base-unix -opam:34:tezos-client-genesis: +opam:35:tezos-client-genesis: <<: *opam_definition variables: package: tezos-client-genesis -opam:35:tezos-embedded-protocol-alpha: - <<: *opam_definition - variables: - package: tezos-embedded-protocol-alpha - -opam:36:tezos-embedded-protocol-demo: - <<: *opam_definition - variables: - package: tezos-embedded-protocol-demo - -opam:37:tezos-embedded-protocol-genesis: - <<: *opam_definition - variables: - package: tezos-embedded-protocol-genesis - -opam:38:tezos-shell: - <<: *opam_definition - variables: - package: tezos-shell - -opam:39:ocplib-ezresto: +opam:36:ocplib-ezresto: <<: *opam_definition variables: package: ocplib-ezresto -opam:40:tezos-client: +opam:37:tezos-embedded-protocol-alpha: + <<: *opam_definition + variables: + package: tezos-embedded-protocol-alpha + +opam:38:tezos-embedded-protocol-demo: + <<: *opam_definition + variables: + package: tezos-embedded-protocol-demo + +opam:39:tezos-embedded-protocol-genesis: + <<: *opam_definition + variables: + package: tezos-embedded-protocol-genesis + +opam:40:tezos-shell: + <<: *opam_definition + variables: + package: tezos-shell + +opam:41:tezos-client: <<: *opam_definition variables: package: tezos-client -opam:41:tezos-node: - <<: *opam_definition - variables: - package: tezos-node - opam:42:ocplib-ezresto-directory: <<: *opam_definition variables: package: ocplib-ezresto-directory -opam:43:tezos-baker-alpha: +opam:43:tezos-clic: + <<: *opam_definition + variables: + package: tezos-clic + +opam:44:tezos-baker-alpha: <<: *opam_definition variables: package: tezos-baker-alpha -opam:44:tezos-protocol-demo: +opam:45:tezos-protocol-demo: <<: *opam_definition variables: package: tezos-protocol-demo -opam:45:tezos-protocol-environment-shell: +opam:46:tezos-node: <<: *opam_definition variables: - package: tezos-protocol-environment-shell + package: tezos-node ##END_OPAM## diff --git a/src/bin_client/client_protocols_commands.ml b/src/bin_client/client_protocols_commands.ml index 97cd8b118..2ca54fe78 100644 --- a/src/bin_client/client_protocols_commands.ml +++ b/src/bin_client/client_protocols_commands.ml @@ -8,11 +8,11 @@ (**************************************************************************) let group = - { Cli_entries.name = "protocols" ; + { Clic.name = "protocols" ; title = "Commands for managing protocols" } let commands () = - let open Cli_entries in + let open Clic in let check_dir _ dn = if Sys.is_directory dn then return dn diff --git a/src/bin_client/client_rpc_commands.ml b/src/bin_client/client_rpc_commands.ml index 74ad96ccb..aa0f80073 100644 --- a/src/bin_client/client_rpc_commands.ml +++ b/src/bin_client/client_rpc_commands.ml @@ -10,7 +10,7 @@ (* Tezos Command line interface - Generic JSON RPC interface *) open Lwt.Infix -open Cli_entries +open Clic open Json_schema (*-- Assisted, schema directed input fill in --------------------------------*) @@ -424,7 +424,7 @@ let call_with_file_or_json url maybe_file (cctxt: #Client_context.full) = call_with_json url json cctxt let group = - { Cli_entries.name = "rpc" ; + { Clic.name = "rpc" ; title = "Commands for the low level RPC layer" } let commands = [ diff --git a/src/lib_base/blake2B.ml b/src/lib_base/blake2B.ml index 9ca48ff36..9cbd9c483 100644 --- a/src/lib_base/blake2B.ml +++ b/src/lib_base/blake2B.ml @@ -51,9 +51,9 @@ module Extend(H : Tezos_crypto.S.HASH) = struct () let param ?(name=H.name) ?(desc=H.title) t = - Cli_entries.param + Clic.param ~name - ~desc (Cli_entries.parameter (fun _ str -> Lwt.return (of_b58check str))) t + ~desc (Clic.parameter (fun _ str -> Lwt.return (of_b58check str))) t module Set = struct include Set.Make(struct type nonrec t = t let compare = compare end) diff --git a/src/lib_base/ed25519.ml b/src/lib_base/ed25519.ml index a17d3f392..ab7ad48c3 100644 --- a/src/lib_base/ed25519.ml +++ b/src/lib_base/ed25519.ml @@ -31,7 +31,7 @@ module Public_key = struct let param ?(name="ed25519-public") ?(desc="Ed25519 public key (b58check-encoded)") t = - Cli_entries.(param ~name ~desc + Clic.(param ~name ~desc (parameter (fun _ str -> Lwt.return (of_b58check str))) t) end @@ -66,7 +66,7 @@ module Secret_key = struct let param ?(name="ed25519-secret") ?(desc="Ed25519 secret key (b58check-encoded)") t = - Cli_entries.(param ~name ~desc + Clic.(param ~name ~desc (parameter (fun _ str -> Lwt.return (of_b58check str))) t) end @@ -100,7 +100,7 @@ module Signature = struct let param ?(name="ed25519-signature") ?(desc="Ed25519 signature (b58check-encoded)") t = - Cli_entries.(param ~name ~desc + Clic.(param ~name ~desc (parameter (fun _ str -> Lwt.return (of_b58check str))) t) end diff --git a/src/lib_base/ed25519.mli b/src/lib_base/ed25519.mli index 63f4c5ff9..e5a8e8e96 100644 --- a/src/lib_base/ed25519.mli +++ b/src/lib_base/ed25519.mli @@ -10,8 +10,8 @@ module Public_key : sig val param: ?name:string -> ?desc:string -> - ('a, 'b) Cli_entries.params -> - (t -> 'a, 'b) Cli_entries.params + ('a, 'b) Clic.params -> + (t -> 'a, 'b) Clic.params val of_b58check: string -> t tzresult end @@ -21,8 +21,8 @@ module Secret_key : sig val param: ?name:string -> ?desc:string -> - ('a, 'b) Cli_entries.params -> - (t -> 'a, 'b) Cli_entries.params + ('a, 'b) Clic.params -> + (t -> 'a, 'b) Clic.params val of_b58check: string -> t tzresult end @@ -32,8 +32,8 @@ module Signature : sig val param: ?name:string -> ?desc:string -> - ('a, 'b) Cli_entries.params -> - (t -> 'a, 'b) Cli_entries.params + ('a, 'b) Clic.params -> + (t -> 'a, 'b) Clic.params val of_b58check: string -> t tzresult end diff --git a/src/lib_base/jbuild b/src/lib_base/jbuild index c1d5b787b..90fe21f2c 100644 --- a/src/lib_base/jbuild +++ b/src/lib_base/jbuild @@ -9,6 +9,7 @@ -open Tezos_data_encoding -open Tezos_error_monad -open Tezos_rpc + -open Tezos_clic -open Tezos_micheline -safe-string)) (libraries (tezos-stdlib @@ -16,6 +17,7 @@ tezos-data-encoding tezos-error-monad tezos-rpc + tezos-clic tezos-micheline re.str calendar diff --git a/src/lib_base/s.ml b/src/lib_base/s.ml index da02629e7..0de4ce991 100644 --- a/src/lib_base/s.ml +++ b/src/lib_base/s.ml @@ -146,8 +146,8 @@ module type INTERNAL_HASH = sig val param: ?name:string -> ?desc:string -> - ('a, 'arg) Cli_entries.params -> - (t -> 'a, 'arg) Cli_entries.params + ('a, 'arg) Clic.params -> + (t -> 'a, 'arg) Clic.params module Set : sig include Set.S with type elt = t @@ -196,8 +196,8 @@ module type INTERNAL_MERKLE_TREE = sig val param: ?name:string -> ?desc:string -> - ('a, 'arg) Cli_entries.params -> - (t -> 'a, 'arg) Cli_entries.params + ('a, 'arg) Clic.params -> + (t -> 'a, 'arg) Clic.params module Set : sig include Set.S with type elt = t diff --git a/src/lib_base/tzPervasives.ml b/src/lib_base/tzPervasives.ml index f66942338..f9e544930 100644 --- a/src/lib_base/tzPervasives.ml +++ b/src/lib_base/tzPervasives.ml @@ -11,6 +11,7 @@ include Tezos_stdlib include Tezos_data_encoding include Tezos_error_monad include Tezos_rpc +include Tezos_clic include Tezos_micheline module Ed25519 = Ed25519 @@ -55,7 +56,6 @@ module P2p_connection = P2p_connection module P2p_stat = P2p_stat module P2p_version = P2p_version -module Cli_entries = Cli_entries module Lwt_exit = Lwt_exit include Utils.Infix diff --git a/src/lib_base/tzPervasives.mli b/src/lib_base/tzPervasives.mli index ad84aa8d7..f2f6b58f9 100644 --- a/src/lib_base/tzPervasives.mli +++ b/src/lib_base/tzPervasives.mli @@ -11,6 +11,7 @@ include (module type of (struct include Tezos_stdlib end)) include (module type of (struct include Tezos_data_encoding end)) include (module type of (struct include Tezos_error_monad end)) include (module type of (struct include Tezos_rpc end)) +include (module type of (struct include Tezos_clic end)) module Ed25519 = Ed25519 module Crypto_box = Crypto_box @@ -52,7 +53,6 @@ module P2p_connection = P2p_connection module P2p_stat = P2p_stat module P2p_version = P2p_version -module Cli_entries = Cli_entries module Lwt_exit = Lwt_exit include (module type of (struct include Utils.Infix end)) diff --git a/src/lib_base/cli_entries.ml b/src/lib_clic/clic.ml similarity index 98% rename from src/lib_base/cli_entries.ml rename to src/lib_clic/clic.ml index 08098af40..68dafbdd4 100644 --- a/src/lib_base/cli_entries.ml +++ b/src/lib_clic/clic.ml @@ -260,7 +260,7 @@ let group_commands commands = let ({ title ; _ }, r) = List.find (fun ({ name ; _ }, _) -> group.name = name) grouped in if title <> group.title then - invalid_arg "Cli_entries.usage: duplicate group name" ; + invalid_arg "Clic.usage: duplicate group name" ; r := command :: !r ; (grouped, ungrouped) with Not_found -> @@ -315,7 +315,7 @@ let setup_formatter ppf format verbosity = let pop_level () = match !levels with | _ :: level :: rest -> levels := level :: rest ; setup_level level - | [ _ ] | [] -> Pervasives.failwith "Cli_entries: unclosed verbosity tag" in + | [ _ ] | [] -> Pervasives.failwith "Clic: unclosed verbosity tag" in push_level (Terse, (<=)) ; let push_level_tag tag = let push op = function @@ -323,7 +323,7 @@ let setup_formatter ppf format verbosity = | "details" -> push_level (Details, op) | "short" -> push_level (Short, op) | "terse" -> push_level (Terse, op) - | tag -> Pervasives.failwith ("Cli_entries: invalid semantic tag <" ^ tag ^ ">") in + | tag -> Pervasives.failwith ("Clic: invalid semantic tag <" ^ tag ^ ">") in if String.length tag > 0 && String.get tag 0 = '=' then push (=) (String.sub tag 1 (String.length tag - 1)) else if String.length tag > 0 && String.get tag 0 = '-' then @@ -333,7 +333,7 @@ let setup_formatter ppf format verbosity = | "full" | "details" | "short" | "terse" | "-full" | "-details" | "-short" | "-terse" | "=full" | "=details" | "=short" | "=terse" -> pop_level () - | tag -> Pervasives.failwith ("Cli_entries: invalid semantic tag <" ^ tag ^ ">") in + | tag -> Pervasives.failwith ("Clic: invalid semantic tag <" ^ tag ^ ">") in match format with | Ansi -> let color_num = function @@ -373,7 +373,7 @@ let setup_formatter ppf format verbosity = | _ :: format :: rest -> ansi_stack := format :: rest ; Format.fprintf ppf "@<0>%a" ansi_format format - | [ _ ] | [] -> Pervasives.failwith "Cli_entries: unclosed ansi format" in + | [ _ ] | [] -> Pervasives.failwith "Clic: unclosed ansi format" in Format.pp_set_formatter_tag_functions ppf { mark_open_tag = (fun _ -> "") ; mark_close_tag = (fun _ -> "") ; @@ -728,7 +728,7 @@ let param ~name ~desc kind next = Param (name, desc, kind, next) let seq_of_param param = match param Stop with | Param (n, desc, parameter, Stop) -> Seq (n, desc, parameter) - | _ -> invalid_arg "Cli_entries.seq_of_param" + | _ -> invalid_arg "Clic.seq_of_param" let prefix keyword next = Prefix (keyword, next) let rec fixed = @@ -876,7 +876,7 @@ let insert_in_dispatch_tree : TParam { l with stop = Some command } | _, _ -> Pervasives.failwith - "Cli_entries.Command_tree.insert: conflicting commands" in + "Clic.Command_tree.insert: conflicting commands" in insert_tree conv root params diff --git a/src/lib_base/cli_entries.mli b/src/lib_clic/clic.mli similarity index 100% rename from src/lib_base/cli_entries.mli rename to src/lib_clic/clic.mli diff --git a/src/lib_clic/jbuild b/src/lib_clic/jbuild new file mode 100644 index 000000000..0a741dd55 --- /dev/null +++ b/src/lib_clic/jbuild @@ -0,0 +1,16 @@ +(jbuild_version 1) + +(library + ((name tezos_clic) + (public_name tezos-clic) + (flags (:standard -w -30 + -safe-string + -open Tezos_stdlib + -open Tezos_error_monad)) + (libraries (tezos-stdlib + tezos-error-monad)))) + +(alias + ((name runtest_indent) + (deps ((glob_files *.ml*))) + (action (run bash ${libexec:tezos-stdlib:test-ocp-indent.sh} ${^})))) diff --git a/src/lib_clic/tezos-clic.opam b/src/lib_clic/tezos-clic.opam new file mode 100644 index 000000000..ce8444a8b --- /dev/null +++ b/src/lib_clic/tezos-clic.opam @@ -0,0 +1,20 @@ +opam-version: "1.2" +version: "dev" +maintainer: "contact@tezos.com" +authors: [ "Tezos devteam" ] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "https://gitlab.com/tezos/tezos.git" +license: "unreleased" +depends: [ + "ocamlfind" { build } + "jbuilder" { build & = "1.0+beta19" } + "tezos-stdlib" + "tezos-error-monad" +] +build: [ + [ "jbuilder" "build" "-p" name "-j" jobs ] +] +build-test: [ + [ "jbuilder" "runtest" "-p" name "-j" jobs ] +] diff --git a/src/lib_client_base/client_aliases.ml b/src/lib_client_base/client_aliases.ml index 562e7c723..ed5264104 100644 --- a/src/lib_client_base/client_aliases.ml +++ b/src/lib_client_base/client_aliases.ml @@ -10,7 +10,7 @@ (* Tezos Command line interface - Local Storage for Configuration *) open Lwt.Infix -open Cli_entries +open Clic module type Entity = sig type t @@ -60,13 +60,13 @@ module type Alias = sig val alias_param : ?name:string -> ?desc:string -> - ('a, (#Client_context.wallet as 'b)) Cli_entries.params -> - (string * t -> 'a, 'b) Cli_entries.params + ('a, (#Client_context.wallet as 'b)) Clic.params -> + (string * t -> 'a, 'b) Clic.params val fresh_alias_param : ?name:string -> ?desc:string -> - ('a, (< .. > as 'obj)) Cli_entries.params -> - (fresh_param -> 'a, 'obj) Cli_entries.params + ('a, (< .. > as 'obj)) Clic.params -> + (fresh_param -> 'a, 'obj) Clic.params val force_switch : unit -> (bool, #Client_context.full) arg val of_fresh : @@ -77,8 +77,8 @@ module type Alias = sig val source_param : ?name:string -> ?desc:string -> - ('a, (#Client_context.wallet as 'obj)) Cli_entries.params -> - (t -> 'a, 'obj) Cli_entries.params + ('a, (#Client_context.wallet as 'obj)) Clic.params -> + (t -> 'a, 'obj) Clic.params val autocomplete: #Client_context.wallet -> string list tzresult Lwt.t end @@ -266,7 +266,7 @@ module Alias = functor (Entity : Entity) -> struct next let force_switch () = - Cli_entries.switch + Clic.switch ~long:"force" ~short:'f' ~doc:("overwrite existing " ^ Entity.name) () diff --git a/src/lib_client_base/client_aliases.mli b/src/lib_client_base/client_aliases.mli index 4e28dc6f9..1400cfcbb 100644 --- a/src/lib_client_base/client_aliases.mli +++ b/src/lib_client_base/client_aliases.mli @@ -56,15 +56,15 @@ module type Alias = sig val alias_param : ?name:string -> ?desc:string -> - ('a, (#Client_context.wallet as 'b)) Cli_entries.params -> - (string * t -> 'a, 'b) Cli_entries.params + ('a, (#Client_context.wallet as 'b)) Clic.params -> + (string * t -> 'a, 'b) Clic.params val fresh_alias_param : ?name:string -> ?desc:string -> - ('a, (< .. > as 'obj)) Cli_entries.params -> - (fresh_param -> 'a, 'obj) Cli_entries.params + ('a, (< .. > as 'obj)) Clic.params -> + (fresh_param -> 'a, 'obj) Clic.params val force_switch : - unit -> (bool, #Client_context.full) Cli_entries.arg + unit -> (bool, #Client_context.full) Clic.arg val of_fresh : #Client_context.wallet -> bool -> @@ -73,8 +73,8 @@ module type Alias = sig val source_param : ?name:string -> ?desc:string -> - ('a, (#Client_context.wallet as 'obj)) Cli_entries.params -> - (t -> 'a, 'obj) Cli_entries.params + ('a, (#Client_context.wallet as 'obj)) Clic.params -> + (t -> 'a, 'obj) Clic.params val autocomplete: #Client_context.wallet -> string list tzresult Lwt.t end diff --git a/src/lib_client_base/client_keys.ml b/src/lib_client_base/client_keys.ml index 4acfa8b44..0228b83b8 100644 --- a/src/lib_client_base/client_keys.ml +++ b/src/lib_client_base/client_keys.ml @@ -281,6 +281,6 @@ let alias_keys cctxt name = in find_key l let force_switch () = - Cli_entries.switch + Clic.switch ~long:"force" ~short:'f' ~doc:"overwrite existing keys" () diff --git a/src/lib_client_base/client_keys.mli b/src/lib_client_base/client_keys.mli index 80c89aace..64ba6ba90 100644 --- a/src/lib_client_base/client_keys.mli +++ b/src/lib_client_base/client_keys.mli @@ -139,4 +139,4 @@ val get_keys: #Client_context.io_wallet -> (string * Public_key_hash.t * Ed25519.Public_key.t * sk_locator) list tzresult Lwt.t -val force_switch : unit -> (bool, #Client_context.full) Cli_entries.arg +val force_switch : unit -> (bool, #Client_context.full) Clic.arg diff --git a/src/lib_client_base/client_tags.ml b/src/lib_client_base/client_tags.ml index 1fec77308..b8b5be6e5 100644 --- a/src/lib_client_base/client_tags.ml +++ b/src/lib_client_base/client_tags.ml @@ -64,7 +64,7 @@ module Tags (Entity : Entity) = struct let desc = desc ^ "\n" ^ "can be one or multiple tags separated by commas" in - Cli_entries.( + Clic.( param ~name ~desc (parameter (fun _ s -> of_source s)) next) diff --git a/src/lib_client_base/client_tags.mli b/src/lib_client_base/client_tags.mli index 69eea0e58..1bedd7e4a 100644 --- a/src/lib_client_base/client_tags.mli +++ b/src/lib_client_base/client_tags.mli @@ -28,8 +28,8 @@ module Tags (Entity : Entity) : sig val tag_param: ?name:string -> ?desc:string -> - ('a, 'ctx) Cli_entries.params -> - (Tag.t -> 'a, 'ctx) Cli_entries.params + ('a, 'ctx) Clic.params -> + (Tag.t -> 'a, 'ctx) Clic.params val rev_find_by_tag: #Client_context.full -> diff --git a/src/lib_client_base_unix/client_config.ml b/src/lib_client_base_unix/client_config.ml index c0276f8d5..7bf72d6ed 100644 --- a/src/lib_client_base_unix/client_config.ml +++ b/src/lib_client_base_unix/client_config.ml @@ -122,7 +122,7 @@ let default_cli_args = { } -open Cli_entries +open Clic let string_parameter () : (string, #Client_context.full) parameter = parameter (fun _ x -> return x) @@ -230,8 +230,8 @@ let read_config_file config_file = let default_config_file_name = "config" let commands config_file cfg = - let open Cli_entries in - let group = { Cli_entries.name = "config" ; + let open Clic in + let group = { Clic.name = "config" ; title = "Commands for editing and viewing the client's config file" } in [ command ~group ~desc:"Show the config file." no_options diff --git a/src/lib_client_base_unix/client_main_run.ml b/src/lib_client_base_unix/client_main_run.ml index af3963ff5..c576c6c9b 100644 --- a/src/lib_client_base_unix/client_main_run.ml +++ b/src/lib_client_base_unix/client_main_run.ml @@ -12,7 +12,7 @@ open Client_context_unix let builtin_commands = - let open Cli_entries in + let open Clic in [ command ~desc: "List the protocol versions that this client understands." @@ -69,10 +69,10 @@ let main select_commands = | _ :: args -> move_autocomplete_token_upfront [] args | [] -> [], None in Random.self_init () ; - ignore Cli_entries.(setup_formatter Format.std_formatter - (if Unix.isatty Unix.stdout then Ansi else Plain) Short) ; - ignore Cli_entries.(setup_formatter Format.err_formatter - (if Unix.isatty Unix.stderr then Ansi else Plain) Short) ; + ignore Clic.(setup_formatter Format.std_formatter + (if Unix.isatty Unix.stdout then Ansi else Plain) Short) ; + ignore Clic.(setup_formatter Format.err_formatter + (if Unix.isatty Unix.stderr then Ansi else Plain) Short) ; init_logger () >>= fun () -> Lwt.catch begin fun () -> begin Client_config.parse_config_args @@ -91,10 +91,10 @@ let main select_commands = let ctxt = new RPC_client.http_ctxt rpc_config Media_type.all_media_types in select_commands ctxt parsed_args >>=? fun commands -> let commands = - Cli_entries.add_manual + Clic.add_manual ~executable_name ~global_options - (if Unix.isatty Unix.stdout then Cli_entries.Ansi else Cli_entries.Plain) + (if Unix.isatty Unix.stdout then Clic.Ansi else Clic.Plain) Format.std_formatter (config_commands @ builtin_commands @ commands) in let rpc_config = @@ -112,26 +112,26 @@ let main select_commands = ~rpc_config:rpc_config in begin match autocomplete with | Some (prev_arg, cur_arg, script) -> - Cli_entries.autocompletion + Clic.autocompletion ~script ~cur_arg ~prev_arg ~args:original_args ~global_options commands client_config >>=? fun completions -> List.iter print_endline completions ; return () | None -> - Cli_entries.dispatch commands client_config remaining + Clic.dispatch commands client_config remaining end end >>= function | Ok () -> Lwt.return 0 - | Error [ Cli_entries.Help command ] -> - Cli_entries.usage + | Error [ Clic.Help command ] -> + Clic.usage Format.std_formatter ~executable_name ~global_options (match command with None -> [] | Some c -> [ c ]) ; Lwt.return 0 | Error errs -> - Cli_entries.pp_cli_errors + Clic.pp_cli_errors Format.err_formatter ~executable_name ~global_options diff --git a/src/lib_client_base_unix/client_main_run.mli b/src/lib_client_base_unix/client_main_run.mli index 83ebca573..fefcf1888 100644 --- a/src/lib_client_base_unix/client_main_run.mli +++ b/src/lib_client_base_unix/client_main_run.mli @@ -10,5 +10,5 @@ val run : (RPC_client.http_ctxt -> Client_config.cli_args -> - Client_context.full Cli_entries.command list tzresult Lwt.t) -> + Client_context.full Clic.command list tzresult Lwt.t) -> unit diff --git a/src/lib_client_commands/client_admin_commands.ml b/src/lib_client_commands/client_admin_commands.ml index ed241a8c7..c0b662bf9 100644 --- a/src/lib_client_commands/client_admin_commands.ml +++ b/src/lib_client_commands/client_admin_commands.ml @@ -8,7 +8,7 @@ (**************************************************************************) let commands () = - let open Cli_entries in + let open Clic in let group = { name = "admin" ; title = "Commands to perform privileged operations on the node" } in [ diff --git a/src/lib_client_commands/client_admin_commands.mli b/src/lib_client_commands/client_admin_commands.mli index 9d3589d13..2ac8569c5 100644 --- a/src/lib_client_commands/client_admin_commands.mli +++ b/src/lib_client_commands/client_admin_commands.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -val commands : unit -> #Client_context.full Cli_entries.command list +val commands : unit -> #Client_context.full Clic.command list diff --git a/src/lib_client_commands/client_commands.ml b/src/lib_client_commands/client_commands.ml index 419484fdd..2f417bc87 100644 --- a/src/lib_client_commands/client_commands.ml +++ b/src/lib_client_commands/client_commands.ml @@ -9,7 +9,7 @@ open Client_context -type command = full Cli_entries.command +type command = full Clic.command exception Version_not_found diff --git a/src/lib_client_commands/client_commands.mli b/src/lib_client_commands/client_commands.mli index 5048fbcc8..eb2fadd94 100644 --- a/src/lib_client_commands/client_commands.mli +++ b/src/lib_client_commands/client_commands.mli @@ -9,7 +9,7 @@ open Client_context -type command = full Cli_entries.command +type command = full Clic.command exception Version_not_found diff --git a/src/lib_client_commands/client_helpers_commands.ml b/src/lib_client_commands/client_helpers_commands.ml index 3d67bbc55..3ea9a349d 100644 --- a/src/lib_client_commands/client_helpers_commands.ml +++ b/src/lib_client_commands/client_helpers_commands.ml @@ -8,13 +8,13 @@ (**************************************************************************) let unique_switch = - Cli_entries.switch + Clic.switch ~long:"unique" ~short:'u' ~doc:"Fail when there is more than one possible completion." () -let commands () = Cli_entries.[ +let commands () = Clic.[ command ~desc: "Autocomplete a prefix of Base58Check-encoded hash.\n\ This actually works only for blocks, operations, public \ diff --git a/src/lib_client_commands/client_keys_commands.ml b/src/lib_client_commands/client_keys_commands.ml index 2316270c9..4df87b58b 100644 --- a/src/lib_client_commands/client_keys_commands.ml +++ b/src/lib_client_commands/client_keys_commands.ml @@ -10,11 +10,11 @@ open Client_keys let group = - { Cli_entries.name = "keys" ; + { Clic.name = "keys" ; title = "Commands for managing the wallet of cryptographic keys" } let commands () = - let open Cli_entries in + let open Clic in let show_private_switch = switch ~long:"show-secret" @@ -195,7 +195,7 @@ let commands () = else return ()) ; command ~group ~desc: "Forget the entire wallet of keys." - (args1 (Cli_entries.switch + (args1 (Clic.switch ~long:"force" ~short:'f' ~doc:"you got to use the force for that" ())) (fixed [ "forget" ; "all" ; "keys" ]) diff --git a/src/lib_client_commands/client_p2p_commands.ml b/src/lib_client_commands/client_p2p_commands.ml index 1c48086eb..5d08fcae1 100644 --- a/src/lib_client_commands/client_p2p_commands.ml +++ b/src/lib_client_commands/client_p2p_commands.ml @@ -8,11 +8,11 @@ (**************************************************************************) let group = - { Cli_entries.name = "p2p" ; + { Clic.name = "p2p" ; title = "Commands for monitoring and controlling p2p-layer state" } let commands () = [ - let open Cli_entries in + let open Clic in command ~group ~desc: "show global network status" no_options (prefixes ["p2p" ; "stat"] stop) begin fun () (cctxt : #Client_context.full) -> diff --git a/src/lib_client_commands/client_report_commands.ml b/src/lib_client_commands/client_report_commands.ml index 0966f0c23..b4db8a5dc 100644 --- a/src/lib_client_commands/client_report_commands.ml +++ b/src/lib_client_commands/client_report_commands.ml @@ -41,7 +41,7 @@ let print_rejected ppf = function invalid let commands () = - let open Cli_entries in + let open Clic in let group = { name = "report" ; title = "Commands to report the node's status" } in let output_arg = @@ -55,7 +55,7 @@ let commands () = | "-" -> return Format.std_formatter | file -> let ppf = Format.formatter_of_out_channel (open_out file) in - ignore Cli_entries.(setup_formatter ppf Plain Full) ; + ignore Clic.(setup_formatter ppf Plain Full) ; return ppf)) in [ command ~group diff --git a/src/lib_client_commands/client_report_commands.mli b/src/lib_client_commands/client_report_commands.mli index 5a87e37b5..a44b49294 100644 --- a/src/lib_client_commands/client_report_commands.mli +++ b/src/lib_client_commands/client_report_commands.mli @@ -8,4 +8,4 @@ (**************************************************************************) -val commands : unit -> #Client_context.full Cli_entries.command list +val commands : unit -> #Client_context.full Clic.command list diff --git a/src/proto_alpha/bin_baker/main_baker_alpha.ml b/src/proto_alpha/bin_baker/main_baker_alpha.ml index 3c88e5678..99340dd7b 100644 --- a/src/proto_alpha/bin_baker/main_baker_alpha.ml +++ b/src/proto_alpha/bin_baker/main_baker_alpha.ml @@ -10,7 +10,7 @@ let select_commands _ _ = return (List.map - (Cli_entries.map_command (new Proto_alpha.wrap_full)) + (Clic.map_command (new Proto_alpha.wrap_full)) (Client_baking_commands.commands ())) let () = Client_main_run.run select_commands diff --git a/src/proto_alpha/lib_baking/client_baking_commands.ml b/src/proto_alpha/lib_baking/client_baking_commands.ml index 113d51761..961ac6dcd 100644 --- a/src/proto_alpha/lib_baking/client_baking_commands.ml +++ b/src/proto_alpha/lib_baking/client_baking_commands.ml @@ -11,11 +11,11 @@ open Client_proto_args open Client_baking_lib let group = - { Cli_entries.name = "delegate" ; + { Clic.name = "delegate" ; title = "Commands related to delegate operations." } let commands () = - let open Cli_entries in + let open Clic in [ command ~group ~desc: "Launch a daemon that handles delegate operations." (args5 max_priority_arg endorsement_delay_arg diff --git a/src/proto_alpha/lib_baking/client_baking_commands.mli b/src/proto_alpha/lib_baking/client_baking_commands.mli index d31b594bf..1cbbf7f78 100644 --- a/src/proto_alpha/lib_baking/client_baking_commands.mli +++ b/src/proto_alpha/lib_baking/client_baking_commands.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -val commands: unit -> Proto_alpha.full Cli_entries.command list +val commands: unit -> Proto_alpha.full Clic.command list diff --git a/src/proto_alpha/lib_baking/client_baking_commands_registration.ml b/src/proto_alpha/lib_baking/client_baking_commands_registration.ml index 46ace44e0..b0c89238a 100644 --- a/src/proto_alpha/lib_baking/client_baking_commands_registration.ml +++ b/src/proto_alpha/lib_baking/client_baking_commands_registration.ml @@ -9,5 +9,5 @@ let () = Client_commands.register Proto_alpha.hash @@ - List.map (Cli_entries.map_command (new Proto_alpha.wrap_full)) @@ + List.map (Clic.map_command (new Proto_alpha.wrap_full)) @@ Client_baking_commands.commands () diff --git a/src/proto_alpha/lib_client/client_proto_args.ml b/src/proto_alpha/lib_client/client_proto_args.ml index eac752d28..57794e017 100644 --- a/src/proto_alpha/lib_client/client_proto_args.ml +++ b/src/proto_alpha/lib_client/client_proto_args.ml @@ -9,7 +9,7 @@ open Proto_alpha open Alpha_context -open Cli_entries +open Clic type error += Bad_tez_arg of string * string (* Arg_name * value *) type error += Bad_max_priority of string @@ -130,7 +130,7 @@ let tez_arg ~default ~parameter ~doc = (tez_parameter ("--" ^ parameter)) let tez_param ~name ~desc next = - Cli_entries.param + Clic.param ~name ~desc:(desc ^ " in \xEA\x9C\xA9\n" ^ tez_format) (tez_parameter name) diff --git a/src/proto_alpha/lib_client/client_proto_args.mli b/src/proto_alpha/lib_client/client_proto_args.mli index 9f4392f43..23d2e00ed 100644 --- a/src/proto_alpha/lib_client/client_proto_args.mli +++ b/src/proto_alpha/lib_client/client_proto_args.mli @@ -12,36 +12,36 @@ open Alpha_context val tez_sym: string -val init_arg: (string, Proto_alpha.full) Cli_entries.arg -val fee_arg: (Tez.t, Proto_alpha.full) Cli_entries.arg -val arg_arg: (string, Proto_alpha.full) Cli_entries.arg -val source_arg: (string option, Proto_alpha.full) Cli_entries.arg +val init_arg: (string, Proto_alpha.full) Clic.arg +val fee_arg: (Tez.t, Proto_alpha.full) Clic.arg +val arg_arg: (string, Proto_alpha.full) Clic.arg +val source_arg: (string option, Proto_alpha.full) Clic.arg -val delegate_arg: (string option, Proto_alpha.full) Cli_entries.arg -val delegatable_switch: (bool, Proto_alpha.full) Cli_entries.arg -val spendable_switch: (bool, Proto_alpha.full) Cli_entries.arg -val max_priority_arg: (int option, Proto_alpha.full) Cli_entries.arg -val free_baking_switch: (bool, Proto_alpha.full) Cli_entries.arg -val force_switch: (bool, Proto_alpha.full) Cli_entries.arg -val endorsement_delay_arg: (int, Proto_alpha.full) Cli_entries.arg +val delegate_arg: (string option, Proto_alpha.full) Clic.arg +val delegatable_switch: (bool, Proto_alpha.full) Clic.arg +val spendable_switch: (bool, Proto_alpha.full) Clic.arg +val max_priority_arg: (int option, Proto_alpha.full) Clic.arg +val free_baking_switch: (bool, Proto_alpha.full) Clic.arg +val force_switch: (bool, Proto_alpha.full) Clic.arg +val endorsement_delay_arg: (int, Proto_alpha.full) Clic.arg -val no_print_source_flag : (bool, Proto_alpha.full) Cli_entries.arg +val no_print_source_flag : (bool, Proto_alpha.full) Clic.arg val tez_arg : default:string -> parameter:string -> doc:string -> - (Tez.t, Proto_alpha.full) Cli_entries.arg + (Tez.t, Proto_alpha.full) Clic.arg val tez_param : name:string -> desc:string -> - ('a, full) Cli_entries.params -> - (Tez.t -> 'a, full) Cli_entries.params + ('a, full) Clic.params -> + (Tez.t -> 'a, full) Clic.params module Daemon : sig - val baking_switch: (bool, Proto_alpha.full) Cli_entries.arg - val endorsement_switch: (bool, Proto_alpha.full) Cli_entries.arg - val denunciation_switch: (bool, Proto_alpha.full) Cli_entries.arg + val baking_switch: (bool, Proto_alpha.full) Clic.arg + val endorsement_switch: (bool, Proto_alpha.full) Clic.arg + val denunciation_switch: (bool, Proto_alpha.full) Clic.arg end -val string_parameter : (string, full) Cli_entries.parameter +val string_parameter : (string, full) Clic.parameter diff --git a/src/proto_alpha/lib_client/client_proto_contracts.ml b/src/proto_alpha/lib_client/client_proto_contracts.ml index bc273d55c..af70e1bc0 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.ml +++ b/src/proto_alpha/lib_client/client_proto_contracts.ml @@ -66,7 +66,7 @@ module ContractAlias = struct desc ^ "\n" ^ "Can be a contract alias or a key alias (autodetected in order).\n\ Use 'key:name' to force the later." in - Cli_entries.( + Clic.( param ~name ~desc (parameter ~autocomplete:autocomplete (fun cctxt p -> get_contract cctxt p)) @@ -77,7 +77,7 @@ module ContractAlias = struct desc ^ "\n" ^ "Can be an alias, a key, or a literal (autodetected in order).\n\ Use 'text:literal', 'alias:name', 'key:name' to force." in - Cli_entries.( + Clic.( param ~name ~desc (parameter ~autocomplete:(fun cctxt -> diff --git a/src/proto_alpha/lib_client/client_proto_contracts.mli b/src/proto_alpha/lib_client/client_proto_contracts.mli index 5a225ba62..96ca06dfc 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.mli +++ b/src/proto_alpha/lib_client/client_proto_contracts.mli @@ -9,7 +9,7 @@ open Proto_alpha open Alpha_context -open Cli_entries +open Clic module RawContractAlias : Client_aliases.Alias with type t = Contract.t diff --git a/src/proto_alpha/lib_client_commands/alpha_commands_registration.ml b/src/proto_alpha/lib_client_commands/alpha_commands_registration.ml index 71ad3f3e8..3da4bb378 100644 --- a/src/proto_alpha/lib_client_commands/alpha_commands_registration.ml +++ b/src/proto_alpha/lib_client_commands/alpha_commands_registration.ml @@ -9,7 +9,7 @@ let () = Client_commands.register Proto_alpha.hash @@ - List.map (Cli_entries.map_command (new Proto_alpha.wrap_full)) @@ + List.map (Clic.map_command (new Proto_alpha.wrap_full)) @@ Client_proto_programs_commands.commands () @ Client_proto_contracts_commands.commands () @ Client_proto_context_commands.commands () diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 85f3ae357..953426732 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -81,15 +81,15 @@ let wait_for_operation_inclusion return () let group = - { Cli_entries.name = "context" ; + { Clic.name = "context" ; title = "Block contextual commands (see option -block)" } let alphanet = - { Cli_entries.name = "alphanet" ; + { Clic.name = "alphanet" ; title = "Alphanet only commands" } let commands () = - let open Cli_entries in + let open Clic in [ command ~group ~desc: "Access the timestamp of the block." no_options diff --git a/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml index 2294dc906..272d9c53b 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_contracts_commands.ml @@ -12,11 +12,11 @@ open Alpha_context open Client_proto_contracts let group = - { Cli_entries.name = "contracts" ; + { Clic.name = "contracts" ; title = "Commands for managing the record of known contracts" } let commands () = - let open Cli_entries in + let open Clic in [ command ~group ~desc: "Add a contract to the wallet." diff --git a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml index db114082b..965533d60 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.ml @@ -10,7 +10,7 @@ open Proto_alpha let group = - { Cli_entries.name = "programs" ; + { Clic.name = "programs" ; title = "Commands for managing the library of known programs" } open Tezos_micheline @@ -18,7 +18,7 @@ open Client_proto_programs open Client_proto_args let commands () = - let open Cli_entries in + let open Clic in let show_types_switch = switch ~long:"details" @@ -42,7 +42,7 @@ let commands () = ~doc:"amount of the transfer in \xEA\x9C\xA9" ~default:"0.05" in let data_parameter = - Cli_entries.parameter (fun _ data -> + Clic.parameter (fun _ data -> Lwt.return (Micheline_parser.no_parsing_error @@ Michelson_v1_parser.parse_expression data)) in [ @@ -87,10 +87,10 @@ let commands () = (prefixes [ "run" ; "program" ] @@ Program.source_param @@ prefixes [ "on" ; "storage" ] - @@ Cli_entries.param ~name:"storage" ~desc:"the storage data" + @@ Clic.param ~name:"storage" ~desc:"the storage data" data_parameter @@ prefixes [ "and" ; "input" ] - @@ Cli_entries.param ~name:"storage" ~desc:"the input data" + @@ Clic.param ~name:"storage" ~desc:"the input data" data_parameter @@ stop) (fun (trace_exec, amount, no_print_source) program storage input cctxt -> @@ -137,10 +137,10 @@ let commands () = command ~group ~desc: "Ask the node to typecheck a data expression." (args1 no_print_source_flag) (prefixes [ "typecheck" ; "data" ] - @@ Cli_entries.param ~name:"data" ~desc:"the data to typecheck" + @@ Clic.param ~name:"data" ~desc:"the data to typecheck" data_parameter @@ prefixes [ "against" ; "type" ] - @@ Cli_entries.param ~name:"type" ~desc:"the expected type" + @@ Clic.param ~name:"type" ~desc:"the expected type" data_parameter @@ stop) (fun no_print_source data ty cctxt -> @@ -162,10 +162,10 @@ let commands () = instruction `H` would have produced." no_options (prefixes [ "hash" ; "data" ] - @@ Cli_entries.param ~name:"data" ~desc:"the data to hash" + @@ Clic.param ~name:"data" ~desc:"the data to hash" data_parameter @@ prefixes [ "of" ; "type" ] - @@ Cli_entries.param ~name:"type" ~desc:"type of the data" + @@ Clic.param ~name:"type" ~desc:"type of the data" data_parameter @@ stop) (fun () data typ cctxt -> @@ -186,10 +186,10 @@ let commands () = instruction `CHECK_SIGNATURE`." no_options (prefixes [ "hash" ; "and" ; "sign" ; "data" ] - @@ Cli_entries.param ~name:"data" ~desc:"the data to hash" + @@ Clic.param ~name:"data" ~desc:"the data to hash" data_parameter @@ prefixes [ "of" ; "type" ] - @@ Cli_entries.param ~name:"type" ~desc:"type of the data" + @@ Clic.param ~name:"type" ~desc:"type of the data" data_parameter @@ prefixes [ "for" ] @@ Client_keys.Secret_key.alias_param diff --git a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.mli b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.mli index d31b594bf..1cbbf7f78 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_programs_commands.mli +++ b/src/proto_alpha/lib_client_commands/client_proto_programs_commands.mli @@ -7,4 +7,4 @@ (* *) (**************************************************************************) -val commands: unit -> Proto_alpha.full Cli_entries.command list +val commands: unit -> Proto_alpha.full Clic.command list diff --git a/src/proto_demo/lib_client/client_proto_main.ml b/src/proto_demo/lib_client/client_proto_main.ml index 0b1992257..08f39ce9a 100644 --- a/src/proto_demo/lib_client/client_proto_main.ml +++ b/src/proto_demo/lib_client/client_proto_main.ml @@ -66,7 +66,7 @@ let handle_error cctxt = function cctxt.Client_commands.error "%s" "cannot continue" let commands () = - let open Cli_entries in + let open Clic in let group = {name = "demo" ; title = "Some demo command" } in [ command ~group ~desc: "A demo command" diff --git a/src/proto_genesis/lib_client/client_proto_main.ml b/src/proto_genesis/lib_client/client_proto_main.ml index 2b93ca58d..0d62a7c99 100644 --- a/src/proto_genesis/lib_client/client_proto_main.ml +++ b/src/proto_genesis/lib_client/client_proto_main.ml @@ -25,17 +25,17 @@ let bake cctxt ?(timestamp = Time.now ()) block command sk = Shell_services.inject_block cctxt signed_blk [] let int64_parameter = - (Cli_entries.parameter (fun _ p -> + (Clic.parameter (fun _ p -> try return (Int64.of_string p) with _ -> failwith "Cannot read int64")) let int_parameter = - (Cli_entries.parameter (fun _ p -> + (Clic.parameter (fun _ p -> try return (int_of_string p) with _ -> failwith "Cannot read int")) let commands () = - let open Cli_entries in + let open Clic in let args = args1 (arg