Client: cleanup / homogeneize command docs

This commit is contained in:
Benjamin Canou 2018-01-29 10:43:07 +01:00 committed by Benjamin Canou
parent 02bc0533fa
commit 2178a6adee
17 changed files with 242 additions and 174 deletions

View File

@ -75,6 +75,8 @@ module type Alias = sig
?desc:string -> ?desc:string ->
('a, (< .. > as 'obj), 'ret) Cli_entries.params -> ('a, (< .. > as 'obj), 'ret) Cli_entries.params ->
(fresh_param -> 'a, 'obj, 'ret) Cli_entries.params (fresh_param -> 'a, 'obj, 'ret) Cli_entries.params
val force_switch :
(bool, Client_commands.full_context) arg
val of_fresh : val of_fresh :
#Client_commands.wallet -> #Client_commands.wallet ->
bool -> bool ->
@ -225,9 +227,15 @@ module Alias = functor (Entity : Entity) -> struct
let source_param ?(name = "src") ?(desc = "source " ^ Entity.name) next = let source_param ?(name = "src") ?(desc = "source " ^ Entity.name) next =
let desc = let desc =
desc ^ "\n" Format.asprintf
^ "can be an alias, file or literal (autodetected in this order)\n\ "%s\n\
use 'file:path', 'text:literal' or 'alias:name' to force" in Can be a %s name, a file or a raw %s literal. If the \
parameter is not the name of an existing %s, the client will \
look for a file containing a %s, and if it does not exist, \
the argument will be read as a raw %s.\n\
Use 'alias:name', 'file:path' or 'text:literal' to disable \
autodetect."
desc Entity.name Entity.name Entity.name Entity.name Entity.name in
param ~name ~desc param ~name ~desc
(parameter (fun cctxt s -> (parameter (fun cctxt s ->
let read path = let read path =
@ -264,6 +272,10 @@ module Alias = functor (Entity : Entity) -> struct
end)) end))
next next
let force_switch =
Client_commands.force_switch
~doc:("overwrite existing " ^ Entity.name) ()
let name (wallet : #wallet) d = let name (wallet : #wallet) d =
rev_find wallet d >>=? function rev_find wallet d >>=? function
| None -> Entity.to_source wallet d | None -> Entity.to_source wallet d

View File

@ -71,6 +71,8 @@ module type Alias = sig
?desc:string -> ?desc:string ->
('a, (< .. > as 'obj), 'ret) Cli_entries.params -> ('a, (< .. > as 'obj), 'ret) Cli_entries.params ->
(fresh_param -> 'a, 'obj, 'ret) Cli_entries.params (fresh_param -> 'a, 'obj, 'ret) Cli_entries.params
val force_switch :
(bool, Client_commands.full_context) Cli_entries.arg
val of_fresh : val of_fresh :
#Client_commands.wallet -> #Client_commands.wallet ->
bool -> bool ->

View File

@ -169,8 +169,5 @@ let commands_for_version version =
try Protocol_hash.Table.find versions version try Protocol_hash.Table.find versions version
with Not_found -> raise Version_not_found with Not_found -> raise Version_not_found
let force_switch = let force_switch ?(doc = "Silence any warnings and some checks.") () =
Cli_entries.switch Cli_entries.switch ~parameter:"-force" ~doc
~parameter:"-force"
~doc:"Take an action that will overwrite data.\
This silences any warnings and some checks"

View File

@ -77,8 +77,8 @@ val commands_for_version: Protocol_hash.t -> command list
val get_versions: unit -> (Protocol_hash.t * (command list)) list val get_versions: unit -> (Protocol_hash.t * (command list)) list
(** Have a command execute ignoring warnings. (** Have a command execute ignoring warnings.
This switch should be used when data will be overwritten. *) Default doc is ["Silence any warnings and some checks."]. *)
val force_switch : (bool, full_context) Cli_entries.arg val force_switch : ?doc:string -> unit -> (bool, full_context) Cli_entries.arg
val default_base_dir : string val default_base_dir : string
val default_block : Block_services.block val default_block : Block_services.block

View File

@ -146,49 +146,50 @@ let base_dir_arg =
arg arg
~parameter:"-base-dir" ~parameter:"-base-dir"
~placeholder:"path" ~placeholder:"path"
~doc:("The directory where the Tezos client will store all its data. By default " ~doc:("client data directory\n\
^ Client_commands.default_base_dir) The directory where the Tezos client will store all its data.\n\
By default " ^ Client_commands.default_base_dir)
string_parameter string_parameter
let config_file_arg = let config_file_arg =
arg arg
~parameter:"-config-file" ~parameter:"-config-file"
~placeholder:"path" ~placeholder:"path"
~doc:"The main configuration file." ~doc:"configuration file"
string_parameter string_parameter
let timings_switch = let timings_switch =
switch switch
~parameter:"-timings" ~parameter:"-timings"
~doc:"Show RPC request times if present." ~doc:"show RPC request times"
let block_arg = let block_arg =
default_arg default_arg
~parameter:"-block" ~parameter:"-block"
~placeholder:"hash|head|head~n" ~placeholder:"hash|tag"
~doc:"The block on which to apply contextual commands." ~doc:"block on which to apply contextual commands"
~default:(Block_services.to_string default_cli_args.block) ~default:(Block_services.to_string default_cli_args.block)
block_parameter block_parameter
let protocol_arg = let protocol_arg =
arg arg
~parameter:"-protocol" ~parameter:"-protocol"
~placeholder:"hash" ~placeholder:"hash"
~doc:"Use contextual commands of a specific protocol." ~doc:"use commands of a specific protocol"
protocol_parameter protocol_parameter
let log_requests_switch = let log_requests_switch =
switch switch
~parameter:"-log-requests" ~parameter:"-log-requests"
~doc:"Causes all requests and responses to the node to be logged." ~doc:"log all requests to the node"
(* Command-line args which can be set in config file as well *) (* Command-line args which can be set in config file as well *)
let addr_arg = let addr_arg =
arg arg
~parameter:"-addr" ~parameter:"-addr"
~placeholder:"IP addr|host" ~placeholder:"IP addr|host"
~doc:"The IP address of the node." ~doc:"IP address of the node"
string_parameter string_parameter
let port_arg = let port_arg =
arg arg
~parameter:"-port" ~parameter:"-port"
~placeholder:"number" ~placeholder:"number"
~doc:"The RPC port of the node." ~doc:"RPC port of the node"
(parameter (parameter
(fun _ x -> try (fun _ x -> try
return (int_of_string x) return (int_of_string x)
@ -197,7 +198,7 @@ let port_arg =
let tls_switch = let tls_switch =
switch switch
~parameter:"-tls" ~parameter:"-tls"
~doc:"Use TLS to connect to node." ~doc:"use TLS to connect to node."
let read_config_file config_file = match let read_config_file config_file = match
Utils.read_file ~bin:false config_file Utils.read_file ~bin:false config_file
@ -205,7 +206,7 @@ let read_config_file config_file = match
with with
| exception (Sys_error msg) -> | exception (Sys_error msg) ->
failwith failwith
"Error: can't read the configuration file: %s@,%s" "Can't read the configuration file: %s@,%s"
config_file msg config_file msg
| Error msg -> | Error msg ->
failwith failwith
@ -224,7 +225,7 @@ let commands config_file cfg =
let open Cli_entries in let open Cli_entries in
let group = { Cli_entries.name = "config" ; let group = { Cli_entries.name = "config" ;
title = "Commands for editing and viewing the client's config file." } in title = "Commands for editing and viewing the client's config file." } in
[ command ~group ~desc:"show the config file" [ command ~group ~desc:"Show the config file."
no_options no_options
(fixed [ "config" ; "show" ]) (fixed [ "config" ; "show" ])
(fun () (cctxt : Client_commands.full_context) -> (fun () (cctxt : Client_commands.full_context) ->
@ -239,19 +240,34 @@ let commands config_file cfg =
read_config_file config_file >>=? fun cfg -> read_config_file config_file >>=? fun cfg ->
cctxt#message "%a@," pp_cfg cfg >>= return) ; cctxt#message "%a@," pp_cfg cfg >>= return) ;
command ~group ~desc:"reset the config file to the factory defaults" command ~group ~desc:"Reset the config file to the factory defaults."
no_options no_options
(fixed [ "config" ; "reset" ]) (fixed [ "config" ; "reset" ])
(fun () _cctxt -> (fun () _cctxt ->
return Cfg_file.(write config_file default)) ; return Cfg_file.(write config_file default)) ;
command ~group ~desc:"update the config based on the current cli values" command ~group
~desc:"Update the config based on the current cli values.\n\
Loads the current configuration (default or as specified \
with `-config-file`), applies alterations from other \
command line arguments (such as the node's address, \
etc.), and overwrites the updated configuration file."
no_options no_options
(fixed [ "config" ; "update" ]) (fixed [ "config" ; "update" ])
(fun () _cctxt -> (fun () _cctxt ->
return Cfg_file.(write config_file cfg)) ; return Cfg_file.(write config_file cfg)) ;
command ~group ~desc:"create a config file based on the current CLI values" command ~group
~desc:"Create a config file based on the current CLI values.\n\
If the `-file` option is not passed, this will initialize \
the default config file, based on default parameters, \
altered by other command line options (such as the node's \
address, etc.).\n\
Otherwise, it will create a new config file, based on the \
default parameters (or the the ones specified with \
`-config-file`), altered by other command line \
options.\n\
The command will always fail if the file already exists."
(args1 (args1
(default_arg (default_arg
~parameter:"-file" ~parameter:"-file"

View File

@ -425,7 +425,8 @@ let group =
let commands = [ let commands = [
command ~desc: "list all understood protocol versions" command
~desc: "List the protocol versions that this client understands."
no_options no_options
(fixed [ "list" ; "versions" ]) (fixed [ "list" ; "versions" ])
(fun () (cctxt : Client_commands.full_context) -> (fun () (cctxt : Client_commands.full_context) ->
@ -434,37 +435,50 @@ let commands = [
(Client_commands.get_versions ()) >>= fun () -> (Client_commands.get_versions ()) >>= fun () ->
return ()) ; return ()) ;
command ~group ~desc: "list available RPCs (low level command for advanced users)" command ~group
~desc: "List RPCs under a given URL prefix.\n\
Some parts of the RPC service hierarchy depend on parameters,\n\
they are marked by a suffix `<dynamic>`.\n\
You can list these sub-hierarchies by providing a concrete URL prefix \
whose arguments are set to a valid value."
no_options
(prefixes [ "rpc" ; "list" ] @@ string ~name:"url" ~desc: "the URL prefix" @@ stop)
(fun () -> list) ;
command ~group
~desc: "Alias to `rpc list /`."
no_options no_options
(prefixes [ "rpc" ; "list" ] @@ stop) (prefixes [ "rpc" ; "list" ] @@ stop)
(fun () -> (list "/")); (fun () -> (list "/"));
command ~group ~desc: "list available RPCs (low level command for advanced users)" command ~group
~desc: "Get the input and output JSON schemas of an RPC."
no_options no_options
(prefixes [ "rpc" ; "list" ] @@ string ~name:"url" ~desc: "the RPC's prefix to be described" @@ stop) (prefixes [ "rpc" ; "schema" ] @@ string ~name: "url" ~desc: "the RPC url" @@ stop)
(fun () -> list) ;
command ~group ~desc: "get the input and output JSON schemas of an RPC"
no_options
(prefixes [ "rpc" ; "schema" ] @@ string ~name: "url" ~desc: "the RPC's URL" @@ stop)
(fun () -> schema) ; (fun () -> schema) ;
command ~group ~desc: "get the humanoid readable input and output formats of an RPC" command ~group
~desc: "Get the humanoid readable input and output formats of an RPC."
no_options no_options
(prefixes [ "rpc" ; "format" ] @@ string ~name: "url" ~desc: "the RPC's URL" @@ stop) (prefixes [ "rpc" ; "format" ] @@ string ~name: "url" ~desc: "the RPC URL" @@ stop)
(fun () -> format) ; (fun () -> format) ;
command ~group ~desc: "call an RPC (low level command for advanced users)" command ~group
~desc: "Call an RPC.\n\
If input data is needed, a text editor will be popped up."
no_options no_options
(prefixes [ "rpc" ; "call" ] @@ string ~name: "url" ~desc: "the RPC's URL" @@ stop) (prefixes [ "rpc" ; "call" ] @@ string ~name: "url" ~desc: "the RPC URL" @@ stop)
(fun () -> call) ; (fun () -> call) ;
command ~group ~desc: "call an RPC (low level command for advanced users)" command ~group
~desc: "Call an RPC providing input data via the command line."
no_options no_options
(prefixes [ "rpc" ; "call" ] @@ string ~name: "url" ~desc: "the RPC's URL" (prefixes [ "rpc" ; "call" ] @@ string ~name: "url" ~desc: "the RPC URL"
@@ prefix "with" @@ prefix "with"
@@ string ~name:"input" @@ string ~name:"input"
~desc:"the JSON input to the RPC or `file:FILENAME`, which is the path to a file containing the JSON" ~desc:"the raw JSON input to the RPC\n\
For instance, use `{}` to send the empty document.\n\
Alternatively, use `file:path` to read the JSON data from a file."
@@ stop) @@ stop)
(fun () -> call_with_file_or_json) (fun () -> call_with_file_or_json)

View File

@ -14,15 +14,14 @@ let unique_switch =
let commands () = Cli_entries.[ let commands () = Cli_entries.[
command command
~desc: "Lookup for the possible completion of a \ ~desc: "Autocomplete a prefix of Base58Check-encoded hash.\n\
given prefix of Base58Check-encoded hash. This actually \ This actually works only for blocks, operations, public \
works only for blocks, operations, public key and contract \ key and contract identifiers."
identifiers."
(args1 unique_switch) (args1 unique_switch)
(prefixes [ "complete" ] @@ (prefixes [ "complete" ] @@
string string
~name: "prefix" ~name: "prefix"
~desc: "the prefix of the Base58Check-encoded hash to be completed" @@ ~desc: "the prefix of the hash to complete" @@
stop) stop)
(fun unique prefix (cctxt : Client_commands.full_context) -> (fun unique prefix (cctxt : Client_commands.full_context) ->
Client_node_rpcs.complete Client_node_rpcs.complete

View File

@ -145,21 +145,23 @@ let alias_keys cctxt name =
else find_key tl else find_key tl
in find_key l in find_key l
let force_switch =
Client_commands.force_switch ~doc:"overwrite existing keys" ()
let group = let group =
{ Cli_entries.name = "keys" ; { Cli_entries.name = "keys" ;
title = "Commands for managing cryptographic keys" } title = "Commands for managing the wallet of cryptographic keys" }
let commands () = let commands () =
let open Cli_entries in let open Cli_entries in
let open Client_commands in
let show_private_switch = let show_private_switch =
switch switch
~parameter:"-show-secret" ~parameter:"-show-secret"
~doc:"Show the private key" in ~doc:"show the private key" in
[ [
command ~group ~desc: "generate a pair of keys" command ~group ~desc: "Generate a pair of keys."
(args1 Client_commands.force_switch) (args1 Secret_key.force_switch)
(prefixes [ "gen" ; "keys" ] (prefixes [ "gen" ; "keys" ]
@@ Secret_key.fresh_alias_param @@ Secret_key.fresh_alias_param
@@ stop) @@ stop)
@ -168,17 +170,19 @@ let commands () =
gen_keys ~force cctxt name) ; gen_keys ~force cctxt name) ;
command ~group ~desc: "Generate keys including the given string" command ~group ~desc: "Generate keys including the given string"
(args2 (switch ~doc:"The key must begin with tz1[containing]" ~parameter:"-prefix") force_switch) (args2
(switch ~doc:"the key must begin with tz1[word]" ~parameter:"-prefix")
force_switch)
(prefixes [ "gen" ; "vanity" ; "keys" ] (prefixes [ "gen" ; "vanity" ; "keys" ]
@@ Public_key_hash.fresh_alias_param @@ Public_key_hash.fresh_alias_param
@@ prefix "matching" @@ prefix "matching"
@@ (seq_of_param @@ string ~name:"strs" ~desc:"String key must contain")) @@ (seq_of_param @@ string ~name:"words" ~desc:"string key must contain one of these words"))
(fun (prefix, force) name containing cctxt -> (fun (prefix, force) name containing cctxt ->
Public_key_hash.of_fresh cctxt force name >>=? fun name -> Public_key_hash.of_fresh cctxt force name >>=? fun name ->
gen_keys_containing ~force ~prefix ~containing ~name cctxt) ; gen_keys_containing ~force ~prefix ~containing ~name cctxt) ;
command ~group ~desc: "add a secret key to the wallet" command ~group ~desc: "Add a secret key to the wallet."
(args1 Client_commands.force_switch) (args1 Secret_key.force_switch)
(prefixes [ "add" ; "secret" ; "key" ] (prefixes [ "add" ; "secret" ; "key" ]
@@ Secret_key.fresh_alias_param @@ Secret_key.fresh_alias_param
@@ Secret_key.source_param @@ Secret_key.source_param
@ -200,8 +204,8 @@ let commands () =
please don't use -force" name) >>=? fun () -> please don't use -force" name) >>=? fun () ->
Secret_key.add ~force cctxt name sk) ; Secret_key.add ~force cctxt name sk) ;
command ~group ~desc: "add a public key to the wallet" command ~group ~desc: "Add a public key to the wallet."
(args1 Client_commands.force_switch) (args1 Public_key.force_switch)
(prefixes [ "add" ; "public" ; "key" ] (prefixes [ "add" ; "public" ; "key" ]
@@ Public_key.fresh_alias_param @@ Public_key.fresh_alias_param
@@ Public_key.source_param @@ Public_key.source_param
@ -212,8 +216,8 @@ let commands () =
name (Ed25519.Public_key.hash key) >>=? fun () -> name (Ed25519.Public_key.hash key) >>=? fun () ->
Public_key.add ~force cctxt name key) ; Public_key.add ~force cctxt name key) ;
command ~group ~desc: "add a public key to the wallet" command ~group ~desc: "Add a public key to the wallet."
(args1 Client_commands.force_switch) (args1 Public_key.force_switch)
(prefixes [ "add" ; "identity" ] (prefixes [ "add" ; "identity" ]
@@ Public_key_hash.fresh_alias_param @@ Public_key_hash.fresh_alias_param
@@ Public_key_hash.source_param @@ Public_key_hash.source_param
@ -222,7 +226,7 @@ let commands () =
Public_key_hash.of_fresh cctxt force name >>=? fun name -> Public_key_hash.of_fresh cctxt force name >>=? fun name ->
Public_key_hash.add ~force cctxt name hash) ; Public_key_hash.add ~force cctxt name hash) ;
command ~group ~desc: "list all public key hashes and associated keys" command ~group ~desc: "List all public key hashes and associated keys."
no_options no_options
(fixed [ "list" ; "known" ; "identities" ]) (fixed [ "list" ; "known" ; "identities" ])
(fun () (cctxt : Client_commands.full_context) -> (fun () (cctxt : Client_commands.full_context) ->
@ -236,7 +240,7 @@ let commands () =
return ()) return ())
l) ; l) ;
command ~group ~desc: "show the keys associated with an identity" command ~group ~desc: "Show the keys associated with an identity."
(args1 show_private_switch) (args1 show_private_switch)
(prefixes [ "show" ; "identity"] (prefixes [ "show" ; "identity"]
@@ Public_key_hash.alias_param @@ Public_key_hash.alias_param
@ -262,8 +266,8 @@ let commands () =
ok_lwt @@ cctxt#message "Secret Key: %s" priv ok_lwt @@ cctxt#message "Secret Key: %s" priv
else return ()) ; else return ()) ;
command ~group ~desc: "forget all keys" command ~group ~desc: "Forget the entire wallet of keys."
(args1 Client_commands.force_switch) (args1 (Client_commands.force_switch ~doc:"you got to use the force for that" ()))
(fixed [ "forget" ; "all" ; "keys" ]) (fixed [ "forget" ; "all" ; "keys" ])
(fun force cctxt -> (fun force cctxt ->
fail_unless force fail_unless force

View File

@ -32,4 +32,6 @@ val gen_keys:
string -> string ->
unit tzresult Lwt.t unit tzresult Lwt.t
val force_switch : (bool, Client_commands.full_context) Cli_entries.arg
val commands: unit -> Client_commands.command list val commands: unit -> Client_commands.command list

View File

@ -21,7 +21,7 @@ let commands () =
let check_dir_parameter = parameter check_dir in let check_dir_parameter = parameter check_dir in
[ [
command ~group ~desc: "list known protocols" command ~group ~desc: "List protocols known by the node."
no_options no_options
(prefixes [ "list" ; "protocols" ] stop) (prefixes [ "list" ; "protocols" ] stop)
(fun () (cctxt : Client_commands.full_context) -> (fun () (cctxt : Client_commands.full_context) ->
@ -30,7 +30,7 @@ let commands () =
return () return ()
); );
command ~group ~desc: "inject a new protocol to the shell database" command ~group ~desc: "Inject a new protocol into the node."
no_options no_options
(prefixes [ "inject" ; "protocol" ] (prefixes [ "inject" ; "protocol" ]
@@ param ~name:"dir" ~desc:"directory containing a protocol" check_dir_parameter @@ param ~name:"dir" ~desc:"directory containing a protocol" check_dir_parameter
@ -53,7 +53,7 @@ let commands () =
return ()) return ())
); );
command ~group ~desc: "dump a protocol from the shell database" command ~group ~desc: "Dump a protocol from the node's record of protocol."
no_options no_options
(prefixes [ "dump" ; "protocol" ] (prefixes [ "dump" ; "protocol" ]
@@ Protocol_hash.param ~name:"protocol hash" ~desc:"" @@ Protocol_hash.param ~name:"protocol hash" ~desc:""

View File

@ -321,20 +321,23 @@ let search_command keyword (Command { params }) =
let rec help_commands commands = let rec help_commands commands =
[ command [ command
~group:help_group ~group:help_group
~desc:"Print documentation of commands. \ ~desc:"Print documentation of commands.\n\
Add search keywords to narrow list. \ Add search keywords to narrow list.\n\
Will display only the commands by default, \ Will display only the commands by default, \
unless [-verbose] is passed or the list \ unless [-verbose] is passed or the list \
of matching commands if less than 3." of matching commands if less than 3."
(args3 (args3
(switch (switch
~doc:"Print terse output, regardless of number of commands returned" ~doc:"Always print terse output.\n\
Only shows command mnemonics, without documentation.\n\
Disables automatic verbosity wrt. number of commands shown."
~parameter:"-terse") ~parameter:"-terse")
(switch (switch
~doc:"Print detailed output, regardless of number of commands returned" ~doc:"Print detailed output.\n\
Disables automatic verbosity wrt. number of commands shown."
~parameter:"-verbose") ~parameter:"-verbose")
(default_arg (default_arg
~doc:"Select the manual's output format" ~doc:"Select the manual's output format."
~placeholder: "plain|colors" ~placeholder: "plain|colors"
~parameter: "-format" ~parameter: "-format"
~default: (if Unix.isatty Unix.stdout then "colors" else "plain") ~default: (if Unix.isatty Unix.stdout then "colors" else "plain")
@ -344,7 +347,10 @@ let rec help_commands commands =
| "colors" -> return `Ansi | "colors" -> return `Ansi
| "plain" -> return `Plain | "plain" -> return `Plain
| _ -> failwith "Unknown manual format")))) | _ -> failwith "Unknown manual format"))))
(prefix "man" @@ seq_of_param (string ~name:"keyword" ~desc:"Keyword to search for")) (prefix "man"
(seq_of_param (string ~name:"keyword"
~desc:"Keyword to search for.\n\
If several are given they must all appear in the command.")))
(fun (terse, details, format) keywords _ -> (fun (terse, details, format) keywords _ ->
if terse && details if terse && details
then fail (Invalid_options_combination "Cannot specify both -verbose and -terse.") then fail (Invalid_options_combination "Cannot specify both -verbose and -terse.")
@ -531,13 +537,15 @@ let print_options_detailed (type ctx) =
let help_option : type a.Format.formatter -> (a, ctx) arg -> unit = let help_option : type a.Format.formatter -> (a, ctx) arg -> unit =
fun ppf -> function fun ppf -> function
| Arg { parameter ; placeholder ; doc } -> | Arg { parameter ; placeholder ; doc } ->
Format.fprintf ppf "@[<v 2>@{<opt>%s <%s>@}:@,@[<hov 0>%a@]@]" Format.fprintf ppf "@[<hov 2>@{<opt>%s <%s>@}: %a@]"
parameter placeholder Format.pp_print_text doc parameter placeholder Format.pp_print_text doc
| DefArg { parameter ; placeholder ; doc ; default } -> | DefArg { parameter ; placeholder ; doc ; default } ->
Format.fprintf ppf "@[<v 2>@{<opt>%s <%s>@} (default %s):@,@[<hov 0>%a@]@]" Format.fprintf ppf "@[<hov 2>@{<opt>%s <%s>@}: %a@]"
parameter placeholder default Format.pp_print_text doc parameter placeholder
Format.pp_print_text
(Format.asprintf "%s\nDefaults to `%s`." doc default)
| Switch { parameter ; doc } -> | Switch { parameter ; doc } ->
Format.fprintf ppf "@[<v 2>@{<opt>%s@}:@,@[<hov 0>%a@]@]" Format.fprintf ppf "@[<hov 2>@{<opt>%s@}: %a@]"
parameter Format.pp_print_text doc parameter Format.pp_print_text doc
in let rec help : type b. Format.formatter -> (b, ctx) args -> unit = in let rec help : type b. Format.formatter -> (b, ctx) args -> unit =
fun ppf -> function fun ppf -> function
@ -616,7 +624,7 @@ let rec print_params_detailed
= fun spec ppf -> function = fun spec ppf -> function
| Stop -> print_options_detailed ppf spec | Stop -> print_options_detailed ppf spec
| Seq (n, desc, _) -> | Seq (n, desc, _) ->
Format.fprintf ppf "@[<v 2>@{<arg>%s@}:@,@[<hov 0>%a@]@]" Format.fprintf ppf "@[<hov 2>@{<arg>%s@}: %a@]"
n Format.pp_print_text (trim desc) ; n Format.pp_print_text (trim desc) ;
begin match spec with begin match spec with
| NoArgs -> () | NoArgs -> ()
@ -625,14 +633,14 @@ let rec print_params_detailed
| Prefix (_, next) -> | Prefix (_, next) ->
print_params_detailed spec ppf next print_params_detailed spec ppf next
| Param (n, desc, _, Stop) -> | Param (n, desc, _, Stop) ->
Format.fprintf ppf "@[<v 2>@{<arg>%s@}:@,@[<hov 0>%a@]@]" Format.fprintf ppf "@[<hov 2>@{<arg>%s@}: %a@]"
n Format.pp_print_text (trim desc); n Format.pp_print_text (trim desc);
begin match spec with begin match spec with
| NoArgs -> () | NoArgs -> ()
| _ -> Format.fprintf ppf "@,%a" print_options_detailed spec | _ -> Format.fprintf ppf "@,%a" print_options_detailed spec
end end
| Param (n, desc, _, next) -> | Param (n, desc, _, next) ->
Format.fprintf ppf "@[<v 2>@{<arg>%s@}:@,@[<hov 0>%a@]@]@,%a" Format.fprintf ppf "@[<hov 2>@{<arg>%s@}: %a@]@,%a"
n Format.pp_print_text (trim desc) (print_params_detailed spec) next n Format.pp_print_text (trim desc) (print_params_detailed spec) next
let contains_params_args : let contains_params_args :

View File

@ -28,7 +28,7 @@ let commands () =
then (true, true, true) then (true, true, true)
else (endorsement, baking, denunciation) in else (endorsement, baking, denunciation) in
run_daemon cctxt ?max_priority ~endorsement_delay ~endorsement ~baking ~denunciation delegates) ; run_daemon cctxt ?max_priority ~endorsement_delay ~endorsement ~baking ~denunciation delegates) ;
command ~group ~desc: "Forge and inject an endorsement operation" command ~group ~desc: "Forge and inject an endorsement operation."
(args1 max_priority_arg) (args1 max_priority_arg)
(prefixes [ "endorse"; "for" ] (prefixes [ "endorse"; "for" ]
@@ Client_keys.Public_key_hash.alias_param @@ Client_keys.Public_key_hash.alias_param
@ -36,7 +36,7 @@ let commands () =
@@ stop) @@ stop)
(fun max_priority (_, delegate) cctxt -> (fun max_priority (_, delegate) cctxt ->
endorse_block cctxt ?max_priority delegate) ; endorse_block cctxt ?max_priority delegate) ;
command ~group ~desc: "Forge and inject block using the delegate rights" command ~group ~desc: "Forge and inject block using the delegate rights."
(args3 max_priority_arg force_switch free_baking_switch) (args3 max_priority_arg force_switch free_baking_switch)
(prefixes [ "bake"; "for" ] (prefixes [ "bake"; "for" ]
@@ Client_keys.Public_key_hash.alias_param @@ Client_keys.Public_key_hash.alias_param
@ -45,13 +45,13 @@ let commands () =
(fun (max_priority, force, free_baking) (_, delegate) cctxt -> (fun (max_priority, force, free_baking) (_, delegate) cctxt ->
bake_block cctxt cctxt#block bake_block cctxt cctxt#block
~force ?max_priority ~free_baking delegate) ; ~force ?max_priority ~free_baking delegate) ;
command ~group ~desc: "Forge and inject a seed-nonce revelation operation" command ~group ~desc: "Forge and inject a seed-nonce revelation operation."
no_options no_options
(prefixes [ "reveal"; "nonce"; "for" ] (prefixes [ "reveal"; "nonce"; "for" ]
@@ seq_of_param Block_hash.param) @@ seq_of_param Block_hash.param)
(fun () block_hashes cctxt -> (fun () block_hashes cctxt ->
reveal_block_nonces cctxt block_hashes) ; reveal_block_nonces cctxt block_hashes) ;
command ~group ~desc: "Forge and inject redemption operations" command ~group ~desc: "Forge and inject redemption operations."
no_options no_options
(prefixes [ "reveal"; "nonces" ] (prefixes [ "reveal"; "nonces" ]
@@ stop) @@ stop)

View File

@ -62,7 +62,7 @@ let init_arg =
default_arg default_arg
~parameter:"-init" ~parameter:"-init"
~placeholder:"data" ~placeholder:"data"
~doc:"The initial value of the contract's storage." ~doc:"initial value of the contract's storage"
~default:"Unit" ~default:"Unit"
string_parameter string_parameter
@ -70,7 +70,7 @@ let arg_arg =
default_arg default_arg
~parameter:"-arg" ~parameter:"-arg"
~placeholder:"data" ~placeholder:"data"
~doc:"The argument passed to the contract's script, if needed." ~doc:"argument passed to the contract's script, if needed"
~default:"Unit" ~default:"Unit"
string_parameter string_parameter
@ -78,7 +78,7 @@ let delegate_arg =
arg arg
~parameter:"-delegate" ~parameter:"-delegate"
~placeholder:"identity" ~placeholder:"identity"
~doc:"Set the delegate of the contract.\ ~doc:"delegate of the contract\n\
Must be a known identity." Must be a known identity."
string_parameter string_parameter
@ -86,28 +86,33 @@ let source_arg =
arg arg
~parameter:"-source" ~parameter:"-source"
~placeholder:"identity" ~placeholder:"identity"
~doc:"Set the source of the bonds to be paid.\ ~doc:"source of the bonds to be paid\n\
Must be a known identity." Must be a known identity."
string_parameter string_parameter
let spendable_switch = let spendable_switch =
switch switch
~parameter:"-spendable" ~parameter:"-spendable"
~doc:"Set the created contract to be spendable" ~doc:"allow the manager to spend the contract's tokens"
let force_switch = let force_switch =
switch switch
~parameter:"-force" ~parameter:"-force"
~doc:"Force the injection of branch-invalid operation or force \ ~doc:"disables the node's injection checks\n\
Force the injection of branch-invalid operation or force \
\ the injection of block without a fitness greater than the \ \ the injection of block without a fitness greater than the \
\ current head." \ current head."
let delegatable_switch = let delegatable_switch =
switch switch
~parameter:"-delegatable" ~parameter:"-delegatable"
~doc:"Set the created contract to be delegatable" ~doc:"allow future delegate change"
let tez_format = "text format: D,DDD,DDD.DDD,DDD (centiles are optional, commas are optional)" let tez_format =
"Text format: `D,DDD,DDD.DDD,DDD`.\n\
Tez and mutez and separated by a period sign. Trailing and pending \
zeroes are allowed. Commas are optional, but if present they must \
be placed every 3 digits."
let tez_parameter param = let tez_parameter param =
parameter parameter
@ -130,13 +135,13 @@ let fee_arg =
tez_arg tez_arg
~default:"0.05" ~default:"0.05"
~parameter:"-fee" ~parameter:"-fee"
~doc:"The fee in \xEA\x9C\xA9 to pay to the baker." ~doc:"fee in \xEA\x9C\xA9 to pay to the baker"
let max_priority_arg = let max_priority_arg =
arg arg
~parameter:"-max-priority" ~parameter:"-max-priority"
~placeholder:"prio" ~placeholder:"slot"
~doc:"Set the max_priority used when looking for baking slot." ~doc:"maximum allowed baking slot"
(parameter (fun _ s -> (parameter (fun _ s ->
try return (int_of_string s) try return (int_of_string s)
with _ -> fail (Bad_max_priority s))) with _ -> fail (Bad_max_priority s)))
@ -144,13 +149,15 @@ let max_priority_arg =
let free_baking_switch = let free_baking_switch =
switch switch
~parameter:"-free-baking" ~parameter:"-free-baking"
~doc:"Only consider free baking slots." ~doc:"only consider free baking slots"
let endorsement_delay_arg = let endorsement_delay_arg =
default_arg default_arg
~parameter:"-endorsement-delay" ~parameter:"-endorsement-delay"
~placeholder:"seconds" ~placeholder:"seconds"
~doc:"Set the delay used before to endorse the current block." ~doc:"delay before endorsing blocks\n\
Delay between notifications of new blocks from the node and \
production of endorsements for these blocks."
~default:"15" ~default:"15"
(parameter (fun _ s -> (parameter (fun _ s ->
try return (int_of_string s) try return (int_of_string s)
@ -159,20 +166,22 @@ let endorsement_delay_arg =
let no_print_source_flag = let no_print_source_flag =
switch switch
~parameter:"-no-print-source" ~parameter:"-no-print-source"
~doc:"Don't print the source code if an error is encountered.\ ~doc:"don't print the source code\n\
This should be enabled for extremely large programs" If an error is encountered, the client will print the \
contract's source code by default.\n\
This option disables this behaviour."
module Daemon = struct module Daemon = struct
let baking_switch = let baking_switch =
switch switch
~parameter:"-baking" ~parameter:"-baking"
~doc:"Run the baking daemon" ~doc:"run the baking daemon"
let endorsement_switch = let endorsement_switch =
switch switch
~parameter:"-endorsement" ~parameter:"-endorsement"
~doc:"Run the endorsement daemon" ~doc:"run the endorsement daemon"
let denunciation_switch = let denunciation_switch =
switch switch
~parameter:"-denunciation" ~parameter:"-denunciation"
~doc:"Run the denunciation daemon" ~doc:"run the denunciation daemon"
end end

View File

@ -37,11 +37,14 @@ let group =
{ Cli_entries.name = "context" ; { Cli_entries.name = "context" ;
title = "Block contextual commands (see option -block)" } title = "Block contextual commands (see option -block)" }
let alphanet =
{ Cli_entries.name = "alphanet" ;
title = "Alphanet only commands" }
let commands () = let commands () =
let open Cli_entries in let open Cli_entries in
let open Client_commands in
[ [
command ~group ~desc: "access the timestamp of the block" command ~group ~desc: "Access the timestamp of the block."
no_options no_options
(fixed [ "get" ; "timestamp" ]) (fixed [ "get" ; "timestamp" ])
begin fun () (cctxt : Client_commands.full_context) -> begin fun () (cctxt : Client_commands.full_context) ->
@ -51,7 +54,7 @@ let commands () =
return () return ()
end ; end ;
command ~group ~desc: "lists all non empty contracts of the block" command ~group ~desc: "Lists all non empty contracts of the block."
no_options no_options
(fixed [ "list" ; "contracts" ]) (fixed [ "list" ; "contracts" ])
begin fun () (cctxt : Client_commands.full_context) -> begin fun () (cctxt : Client_commands.full_context) ->
@ -62,7 +65,7 @@ let commands () =
return () return ()
end ; end ;
command ~group ~desc: "get the balance of a contract" command ~group ~desc: "Get the balance of a contract."
no_options no_options
(prefixes [ "get" ; "balance" ; "for" ] (prefixes [ "get" ; "balance" ; "for" ]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract" @@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@ -73,7 +76,7 @@ let commands () =
return () return ()
end ; end ;
command ~group ~desc: "get the storage of a contract" command ~group ~desc: "Get the storage of a contract."
no_options no_options
(prefixes [ "get" ; "storage" ; "for" ] (prefixes [ "get" ; "storage" ; "for" ]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract" @@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@ -87,7 +90,7 @@ let commands () =
return () return ()
end ; end ;
command ~group ~desc: "get the manager of a contract" command ~group ~desc: "Get the manager of a contract."
no_options no_options
(prefixes [ "get" ; "manager" ; "for" ] (prefixes [ "get" ; "manager" ; "for" ]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract" @@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@ -102,7 +105,7 @@ let commands () =
return () return ()
end ; end ;
command ~group ~desc: "get the delegate of a contract" command ~group ~desc: "Get the delegate of a contract."
no_options no_options
(prefixes [ "get" ; "delegate" ; "for" ] (prefixes [ "get" ; "delegate" ; "for" ]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract" @@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@ -117,13 +120,13 @@ let commands () =
return () return ()
end ; end ;
command ~group ~desc: "set the delegate of a contract" command ~group ~desc: "Set the delegate of a contract."
(args1 fee_arg) (args1 fee_arg)
(prefixes [ "set" ; "delegate" ; "for" ] (prefixes [ "set" ; "delegate" ; "for" ]
@@ ContractAlias.destination_param ~name:"src" ~desc:"source contract" @@ ContractAlias.destination_param ~name:"src" ~desc:"source contract"
@@ prefix "to" @@ prefix "to"
@@ Public_key_hash.alias_param @@ Public_key_hash.alias_param
~name: "mgr" ~desc: "New delegate of the contract" ~name: "mgr" ~desc: "new delegate of the contract"
@@ stop) @@ stop)
begin fun fee (_, contract) (_, delegate) cctxt -> begin fun fee (_, contract) (_, delegate) cctxt ->
source_to_keys cctxt cctxt#block contract >>=? fun (src_pk, manager_sk) -> source_to_keys cctxt cctxt#block contract >>=? fun (src_pk, manager_sk) ->
@ -131,8 +134,8 @@ let commands () =
operation_submitted_message cctxt oph operation_submitted_message cctxt oph
end ; end ;
command ~group ~desc:"open a new account" command ~group ~desc:"Open a new account."
(args4 fee_arg delegate_arg delegatable_switch force_switch) (args4 fee_arg delegate_arg delegatable_switch Client_keys.force_switch)
(prefixes [ "originate" ; "account" ] (prefixes [ "originate" ; "account" ]
@@ RawContractAlias.fresh_alias_param @@ RawContractAlias.fresh_alias_param
~name: "new" ~desc: "name of the new contract" ~name: "new" ~desc: "name of the new contract"
@ -167,9 +170,9 @@ let commands () =
operation_submitted_message ~contracts:[ contract ] cctxt oph operation_submitted_message ~contracts:[ contract ] cctxt oph
end ; end ;
command ~group ~desc: "Launch a smart contract on the blockchain" command ~group ~desc: "Launch a smart contract on the blockchain."
(args7 (args7
fee_arg delegate_arg force_switch fee_arg delegate_arg Client_keys.force_switch
delegatable_switch spendable_switch init_arg no_print_source_flag) delegatable_switch spendable_switch init_arg no_print_source_flag)
(prefixes [ "originate" ; "contract" ] (prefixes [ "originate" ; "contract" ]
@@ RawContractAlias.fresh_alias_param @@ RawContractAlias.fresh_alias_param
@ -186,7 +189,7 @@ let commands () =
@@ prefix "running" @@ prefix "running"
@@ Program.source_param @@ Program.source_param
~name:"prg" ~desc: "script of the account\n\ ~name:"prg" ~desc: "script of the account\n\
combine with -init if the storage type is not unit" Combine with -init if the storage type is not unit."
@@ stop) @@ stop)
begin fun (fee, delegate, force, delegatable, spendable, initial_storage, no_print_source) begin fun (fee, delegate, force, delegatable, spendable, initial_storage, no_print_source)
alias_name (_, manager) balance (_, source) program (cctxt : Client_commands.full_context) -> alias_name (_, manager) balance (_, source) program (cctxt : Client_commands.full_context) ->
@ -204,24 +207,7 @@ let commands () =
~contracts:[contract] oph ~contracts:[contract] oph
end ; end ;
command ~group ~desc: "open a new (free) account" command ~group ~desc: "Transfer tokens / call a smart contract."
(args1 force_switch)
(prefixes [ "originate" ; "free" ; "account" ]
@@ RawContractAlias.fresh_alias_param
~name: "new" ~desc: "name of the new contract"
@@ prefix "for"
@@ Public_key_hash.alias_param
~name: "mgr" ~desc: "manager of the new contract"
@@ stop)
begin fun force alias_name (_, manager_pkh) cctxt ->
RawContractAlias.of_fresh cctxt force alias_name >>=? fun alias_name ->
faucet ~manager_pkh cctxt#block cctxt () >>=? fun (oph, contract) ->
operation_submitted_message cctxt
~contracts:[contract] oph >>=? fun () ->
save_contract ~force cctxt alias_name contract
end;
command ~group ~desc: "transfer tokens"
(args3 fee_arg arg_arg no_print_source_flag) (args3 fee_arg arg_arg no_print_source_flag)
(prefixes [ "transfer" ] (prefixes [ "transfer" ]
@@ tez_param @@ tez_param
@ -243,14 +229,31 @@ let commands () =
operation_submitted_message cctxt ~contracts oph operation_submitted_message cctxt ~contracts oph
end; end;
command ~desc: "Activate a protocol" command ~group:alphanet ~desc: "Open a new FREE account (Alphanet only)."
(args1 force_switch)
(prefixes [ "originate" ; "free" ; "account" ]
@@ RawContractAlias.fresh_alias_param
~name: "new" ~desc: "name of the new contract"
@@ prefix "for"
@@ Public_key_hash.alias_param
~name: "mgr" ~desc: "manager of the new contract"
@@ stop)
begin fun force alias_name (_, manager_pkh) cctxt ->
RawContractAlias.of_fresh cctxt force alias_name >>=? fun alias_name ->
faucet ~manager_pkh cctxt#block cctxt () >>=? fun (oph, contract) ->
operation_submitted_message cctxt
~contracts:[contract] oph >>=? fun () ->
save_contract ~force cctxt alias_name contract
end;
command ~group:alphanet ~desc: "Activate a protocol (Alphanet dictator only)."
no_options no_options
(prefixes [ "activate" ; "protocol" ] (prefixes [ "activate" ; "protocol" ]
@@ Protocol_hash.param ~name:"version" @@ Protocol_hash.param ~name:"version"
~desc:"Protocol version (b58check)" ~desc:"protocol version (b58check)"
@@ prefixes [ "with" ; "key" ] @@ prefixes [ "with" ; "key" ]
@@ Environment.Ed25519.Secret_key.param @@ Environment.Ed25519.Secret_key.param
~name:"password" ~desc:"Dictator's key" ~name:"password" ~desc:"dictator's key"
@@ stop) @@ stop)
begin fun () hash seckey cctxt -> begin fun () hash seckey cctxt ->
dictate cctxt cctxt#block dictate cctxt cctxt#block
@ -258,14 +261,14 @@ let commands () =
operation_submitted_message cctxt oph operation_submitted_message cctxt oph
end ; end ;
command ~desc: "Fork a test protocol" command ~group:alphanet ~desc: "Fork a test protocol (Alphanet dictator only)."
no_options no_options
(prefixes [ "fork" ; "test" ; "protocol" ] (prefixes [ "fork" ; "test" ; "protocol" ]
@@ Protocol_hash.param ~name:"version" @@ Protocol_hash.param ~name:"version"
~desc:"Protocol version (b58check)" ~desc:"protocol version (b58check)"
@@ prefixes [ "with" ; "key" ] @@ prefixes [ "with" ; "key" ]
@@ Environment.Ed25519.Secret_key.param @@ Environment.Ed25519.Secret_key.param
~name:"password" ~desc:"Dictator's key" ~name:"password" ~desc:"dictator's key"
@@ stop) @@ stop)
begin fun () hash seckey cctxt -> begin fun () hash seckey cctxt ->
dictate cctxt cctxt#block dictate cctxt cctxt#block

View File

@ -64,8 +64,8 @@ module ContractAlias = struct
let alias_param ?(name = "name") ?(desc = "existing contract alias") next = let alias_param ?(name = "name") ?(desc = "existing contract alias") next =
let desc = let desc =
desc ^ "\n" desc ^ "\n"
^ "can be a contract alias or a key alias (autodetected in this order)\n\ ^ "Can be a contract alias or a key alias (autodetected in order).\n\
use 'key:name' to force the later" in Use 'key:name' to force the later." in
Cli_entries.( Cli_entries.(
param ~name ~desc param ~name ~desc
(parameter ~autocomplete:autocomplete (parameter ~autocomplete:autocomplete
@ -75,8 +75,8 @@ module ContractAlias = struct
let destination_param ?(name = "dst") ?(desc = "destination contract") next = let destination_param ?(name = "dst") ?(desc = "destination contract") next =
let desc = let desc =
desc ^ "\n" desc ^ "\n"
^ "can be an alias, a key alias, or a literal (autodetected in this order)\n\ ^ "Can be an alias, a key, or a literal (autodetected in order).\n\
use 'text:literal', 'alias:name', 'key:name' to force" in Use 'text:literal', 'alias:name', 'key:name' to force." in
Cli_entries.( Cli_entries.(
param ~name ~desc param ~name ~desc
(parameter (parameter

View File

@ -19,8 +19,8 @@ let commands () =
let open Cli_entries in let open Cli_entries in
[ [
command ~group ~desc: "add a contract to the wallet" command ~group ~desc: "Add a contract to the wallet."
(args1 Client_commands.force_switch) (args1 RawContractAlias.force_switch)
(prefixes [ "remember" ; "contract" ] (prefixes [ "remember" ; "contract" ]
@@ RawContractAlias.fresh_alias_param @@ RawContractAlias.fresh_alias_param
@@ RawContractAlias.source_param @@ RawContractAlias.source_param
@ -29,7 +29,7 @@ let commands () =
RawContractAlias.of_fresh cctxt force name >>=? fun name -> RawContractAlias.of_fresh cctxt force name >>=? fun name ->
RawContractAlias.add ~force cctxt name hash) ; RawContractAlias.add ~force cctxt name hash) ;
command ~group ~desc: "remove a contract from the wallet" command ~group ~desc: "Remove a contract from the wallet."
no_options no_options
(prefixes [ "forget" ; "contract" ] (prefixes [ "forget" ; "contract" ]
@@ RawContractAlias.alias_param @@ RawContractAlias.alias_param
@ -37,7 +37,7 @@ let commands () =
(fun () (name, _) cctxt -> (fun () (name, _) cctxt ->
RawContractAlias.del cctxt name) ; RawContractAlias.del cctxt name) ;
command ~group ~desc: "lists all known contracts" command ~group ~desc: "Lists all known contracts in the wallet."
no_options no_options
(fixed [ "list" ; "known" ; "contracts" ]) (fixed [ "list" ; "known" ; "contracts" ])
(fun () (cctxt : Client_commands.full_context) -> (fun () (cctxt : Client_commands.full_context) ->
@ -48,8 +48,8 @@ let commands () =
(Contract.to_b58check contract) >>= return) (Contract.to_b58check contract) >>= return)
contracts) ; contracts) ;
command ~group ~desc: "forget all known contracts" command ~group ~desc: "Forget the entire wallet of known contracts."
(args1 Client_commands.force_switch) (args1 RawContractAlias.force_switch)
(fixed [ "forget" ; "all" ; "contracts" ]) (fixed [ "forget" ; "all" ; "contracts" ])
(fun force cctxt -> (fun force cctxt ->
fail_unless fail_unless
@ -57,7 +57,7 @@ let commands () =
(failure "this can only used with option -force") >>=? fun () -> (failure "this can only used with option -force") >>=? fun () ->
RawContractAlias.set cctxt []) ; RawContractAlias.set cctxt []) ;
command ~group ~desc: "display a contract from the wallet" command ~group ~desc: "Display a contract from the wallet."
no_options no_options
(prefixes [ "show" ; "known" ; "contract" ] (prefixes [ "show" ; "known" ; "contract" ]
@@ RawContractAlias.alias_param @@ RawContractAlias.alias_param
@ -66,7 +66,7 @@ let commands () =
cctxt#message "%a\n%!" Contract.pp contract >>= fun () -> cctxt#message "%a\n%!" Contract.pp contract >>= fun () ->
return ()) ; return ()) ;
command ~group ~desc: "tag a contract in the wallet" command ~group ~desc: "Tag a contract in the wallet."
no_options no_options
(prefixes [ "tag" ; "contract" ] (prefixes [ "tag" ; "contract" ]
@@ RawContractAlias.alias_param @@ RawContractAlias.alias_param
@ -81,7 +81,7 @@ let commands () =
| Some tags -> List.merge2 tags new_tags in | Some tags -> List.merge2 tags new_tags in
Contract_tags.update cctxt alias new_tags) ; Contract_tags.update cctxt alias new_tags) ;
command ~group ~desc: "remove tag(s) from a contract in the wallet" command ~group ~desc: "Remove tag(s) from a contract in the wallet."
no_options no_options
(prefixes [ "untag" ; "contract" ] (prefixes [ "untag" ; "contract" ]
@@ RawContractAlias.alias_param @@ RawContractAlias.alias_param

View File

@ -9,7 +9,7 @@
let group = let group =
{ Cli_entries.name = "programs" ; { Cli_entries.name = "programs" ;
title = "Commands for managing the record of known programs" } title = "Commands for managing the library of known programs" }
open Tezos_micheline open Tezos_micheline
open Client_proto_programs open Client_proto_programs
@ -20,19 +20,19 @@ let commands () =
let show_types_switch = let show_types_switch =
switch switch
~parameter:"-details" ~parameter:"-details"
~doc:"Show the types of each instruction" in ~doc:"show the types of each instruction" in
let emacs_mode_switch = let emacs_mode_switch =
switch switch
~parameter:"-emacs" ~parameter:"-emacs"
~doc:"Output in michelson-mode.el compatible format" in ~doc:"output in `michelson-mode.el` compatible format" in
let trace_stack_switch = let trace_stack_switch =
switch switch
~parameter:"-trace-stack" ~parameter:"-trace-stack"
~doc:"Show the stack after each step" in ~doc:"show the stack after each step" in
let amount_arg = let amount_arg =
Client_proto_args.tez_arg Client_proto_args.tez_arg
~parameter:"-amount" ~parameter:"-amount"
~doc:"The amount of the transfer in \xEA\x9C\xA9." ~doc:"amount of the transfer in \xEA\x9C\xA9"
~default:"0.05" in ~default:"0.05" in
let data_parameter = let data_parameter =
Cli_entries.parameter (fun _ data -> Cli_entries.parameter (fun _ data ->
@ -40,7 +40,7 @@ let commands () =
@@ Michelson_v1_parser.parse_expression data)) in @@ Michelson_v1_parser.parse_expression data)) in
[ [
command ~group ~desc: "lists all known programs" command ~group ~desc: "Lists all programs in the library."
no_options no_options
(fixed [ "list" ; "known" ; "programs" ]) (fixed [ "list" ; "known" ; "programs" ])
(fun () (cctxt : Client_commands.full_context) -> (fun () (cctxt : Client_commands.full_context) ->
@ -48,8 +48,8 @@ let commands () =
Lwt_list.iter_s (fun (n, _) -> cctxt#message "%s" n) list >>= fun () -> Lwt_list.iter_s (fun (n, _) -> cctxt#message "%s" n) list >>= fun () ->
return ()) ; return ()) ;
command ~group ~desc: "remember a program under some name" command ~group ~desc: "Add a program to the library."
(args1 Client_commands.force_switch) (args1 Program.force_switch)
(prefixes [ "remember" ; "program" ] (prefixes [ "remember" ; "program" ]
@@ Program.fresh_alias_param @@ Program.fresh_alias_param
@@ Program.source_param @@ Program.source_param
@ -58,14 +58,14 @@ let commands () =
Program.of_fresh cctxt force name >>=? fun name -> Program.of_fresh cctxt force name >>=? fun name ->
Program.add ~force cctxt name hash) ; Program.add ~force cctxt name hash) ;
command ~group ~desc: "forget a remembered program" command ~group ~desc: "Remove a program from the library."
no_options no_options
(prefixes [ "forget" ; "program" ] (prefixes [ "forget" ; "program" ]
@@ Program.alias_param @@ Program.alias_param
@@ stop) @@ stop)
(fun () (name, _) cctxt -> Program.del cctxt name) ; (fun () (name, _) cctxt -> Program.del cctxt name) ;
command ~group ~desc: "display a program" command ~group ~desc: "Display a program from the library."
no_options no_options
(prefixes [ "show" ; "known" ; "program" ] (prefixes [ "show" ; "known" ; "program" ]
@@ Program.alias_param @@ Program.alias_param
@ -75,7 +75,7 @@ let commands () =
cctxt#message "%s\n" source >>= fun () -> cctxt#message "%s\n" source >>= fun () ->
return ()) ; return ()) ;
command ~group ~desc: "ask the node to run a program" command ~group ~desc: "Ask the node to run a program."
(args3 trace_stack_switch amount_arg no_print_source_flag) (args3 trace_stack_switch amount_arg no_print_source_flag)
(prefixes [ "run" ; "program" ] (prefixes [ "run" ; "program" ]
@@ Program.source_param @@ Program.source_param
@ -96,7 +96,7 @@ let commands () =
run ~amount ~program ~storage ~input cctxt#block cctxt >>= fun res -> run ~amount ~program ~storage ~input cctxt#block cctxt >>= fun res ->
print_run_result cctxt ~show_source ~parsed:program res)) ; print_run_result cctxt ~show_source ~parsed:program res)) ;
command ~group ~desc: "ask the node to typecheck a program" command ~group ~desc: "Ask the node to typecheck a program."
(args3 show_types_switch emacs_mode_switch no_print_source_flag) (args3 show_types_switch emacs_mode_switch no_print_source_flag)
(prefixes [ "typecheck" ; "program" ] (prefixes [ "typecheck" ; "program" ]
@@ Program.source_param @@ Program.source_param
@ -112,7 +112,7 @@ let commands () =
res res
cctxt) ; cctxt) ;
command ~group ~desc: "ask the node to typecheck a data expression" command ~group ~desc: "Ask the node to typecheck a data expression."
(args1 no_print_source_flag) (args1 no_print_source_flag)
(prefixes [ "typecheck" ; "data" ] (prefixes [ "typecheck" ; "data" ]
@@ Cli_entries.param ~name:"data" ~desc:"the data to typecheck" @@ Cli_entries.param ~name:"data" ~desc:"the data to typecheck"
@ -135,14 +135,15 @@ let commands () =
cctxt#error "ill-typed data") ; cctxt#error "ill-typed data") ;
command ~group command ~group
~desc: "ask the node to compute the hash of a data expression \ ~desc: "Ask the node to hash a data expression.\n\
using the same algorithm as script instruction H" The returned hash is the same as what Michelson \
instruction `H` would have produced."
no_options no_options
(prefixes [ "hash" ; "data" ] (prefixes [ "hash" ; "data" ]
@@ Cli_entries.param ~name:"data" ~desc:"the data to hash" @@ Cli_entries.param ~name:"data" ~desc:"the data to hash"
data_parameter data_parameter
@@ prefixes [ "of" ; "type" ] @@ prefixes [ "of" ; "type" ]
@@ Cli_entries.param ~name:"type" ~desc:"the type of the data" @@ Cli_entries.param ~name:"type" ~desc:"type of the data"
data_parameter data_parameter
@@ stop) @@ stop)
(fun () data typ cctxt -> (fun () data typ cctxt ->
@ -156,16 +157,17 @@ let commands () =
cctxt#error "ill-formed data") ; cctxt#error "ill-formed data") ;
command ~group command ~group
~desc: "ask the node to compute the hash of a data expression \ ~desc: "Ask the node to hash a data expression.\n\
using the same algorithm as script instruction H, sign it using \ Uses the same algorithm as Michelson instruction `H` to \
a given secret key, and display it using the format expected by \ produce the hash, signs it using a given secret key, and \
script instruction CHECK_SIGNATURE" displays it using the format expected by Michelson \
instruction `CHECK_SIGNATURE`."
no_options no_options
(prefixes [ "hash" ; "and" ; "sign" ; "data" ] (prefixes [ "hash" ; "and" ; "sign" ; "data" ]
@@ Cli_entries.param ~name:"data" ~desc:"the data to hash" @@ Cli_entries.param ~name:"data" ~desc:"the data to hash"
data_parameter data_parameter
@@ prefixes [ "of" ; "type" ] @@ prefixes [ "of" ; "type" ]
@@ Cli_entries.param ~name:"type" ~desc:"the type of the data" @@ Cli_entries.param ~name:"type" ~desc:"type of the data"
data_parameter data_parameter
@@ prefixes [ "for" ] @@ prefixes [ "for" ]
@@ Client_keys.Secret_key.alias_param @@ Client_keys.Secret_key.alias_param