From 32625bb075de1c5b36356ea24267ebc449310995 Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Thu, 21 Nov 2019 11:06:25 -0600 Subject: [PATCH 1/3] Use `doc` not `docs` in cli --- src/bin/cli.ml | 28 ++++++------ src/bin/expect_tests/help_tests.ml | 73 ++++++++++++++++-------------- 2 files changed, 54 insertions(+), 47 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index 4b8245e73..7a9eeba5c 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -95,8 +95,8 @@ let compile_file = let term = Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format $ michelson_code_format) in let cmdname = "compile-contract" in - let docs = "Subcommand: compile a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in - (term , Term.info ~docs cmdname) + let doc = "Subcommand: compile a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in + (term , Term.info ~doc cmdname) let compile_parameter = let f source_file entry_point expression syntax display_format michelson_format = @@ -109,8 +109,8 @@ let compile_parameter = let term = Term.(const f $ source_file 0 $ entry_point 1 $ expression "PARAMETER" 2 $ syntax $ display_format $ michelson_code_format) in let cmdname = "compile-parameter" in - let docs = "Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which calls a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in - (term , Term.info ~docs cmdname) + let doc = "Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which calls a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in + (term , Term.info ~doc cmdname) let compile_storage = let f source_file entry_point expression syntax display_format michelson_format = @@ -123,8 +123,8 @@ let compile_storage = let term = Term.(const f $ source_file 0 $ entry_point 1 $ expression "STORAGE" 2 $ syntax $ display_format $ michelson_code_format) in let cmdname = "compile-storage" in - let docs = "Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in - (term , Term.info ~docs cmdname) + let doc = "Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in + (term , Term.info ~doc cmdname) let dry_run = let f source_file entry_point storage input amount sender source syntax display_format = @@ -138,8 +138,8 @@ let dry_run = let term = Term.(const f $ source_file 0 $ entry_point 1 $ expression "PARAMETER" 2 $ expression "STORAGE" 3 $ amount $ sender $ source $ syntax $ display_format) in let cmdname = "dry-run" in - let docs = "Subcommand: run a smart-contract with the given storage and input." in - (term , Term.info ~docs cmdname) + let doc = "Subcommand: run a smart-contract with the given storage and input." in + (term , Term.info ~doc cmdname) let run_function = let f source_file entry_point parameter amount sender source syntax display_format = @@ -153,8 +153,8 @@ let run_function = let term = Term.(const f $ source_file 0 $ entry_point 1 $ expression "PARAMETER" 2 $ amount $ sender $ source $ syntax $ display_format) in let cmdname = "run-function" in - let docs = "Subcommand: run a function with the given parameter." in - (term , Term.info ~docs cmdname) + let doc = "Subcommand: run a function with the given parameter." in + (term , Term.info ~doc cmdname) let evaluate_value = let f source_file entry_point amount sender source syntax display_format = @@ -168,8 +168,8 @@ let evaluate_value = let term = Term.(const f $ source_file 0 $ entry_point 1 $ amount $ sender $ source $ syntax $ display_format) in let cmdname = "evaluate-value" in - let docs = "Subcommand: evaluate a given definition." in - (term , Term.info ~docs cmdname) + let doc = "Subcommand: evaluate a given definition." in + (term , Term.info ~doc cmdname) let compile_expression = let f expression syntax display_format michelson_format = @@ -184,8 +184,8 @@ let compile_expression = let term = Term.(const f $ expression "" 0 $ syntax $ display_format $ michelson_code_format) in let cmdname = "compile-expression" in - let docs = "Subcommand: compile to a michelson value." in - (term , Term.info ~docs cmdname) + let doc = "Subcommand: compile to a michelson value." in + (term , Term.info ~doc cmdname) let run ?argv () = Term.eval_choice ?argv main [ diff --git a/src/bin/expect_tests/help_tests.ml b/src/bin/expect_tests/help_tests.ml index c16365feb..c740f11ea 100644 --- a/src/bin/expect_tests/help_tests.ml +++ b/src/bin/expect_tests/help_tests.ml @@ -13,40 +13,35 @@ let%expect_test _ = SYNOPSIS ligo COMMAND ... - Subcommand: compile a contract. See `ligo compile-contract --help' for a list - of options specific to this subcommand. + COMMANDS compile-contract + Subcommand: compile a contract. See `ligo compile-contract --help' + for a list of options specific to this subcommand. - - Subcommand: compile an initial storage in ligo syntax to a michelson - expression. The resulting michelson expression can be passed as an argument - in a transaction which originates a contract. See `ligo compile-storage - --help' for a list of options specific to this subcommand. - compile-storage - - - Subcommand: compile parameters to a michelson expression. The resulting - michelson expression can be passed as an argument in a transaction which - calls a contract. See `ligo compile-parameter --help' for a list of options - specific to this subcommand. - compile-parameter - - - Subcommand: compile to a michelson value. compile-expression + Subcommand: compile to a michelson value. + compile-parameter + Subcommand: compile parameters to a michelson expression. The + resulting michelson expression can be passed as an argument in a + transaction which calls a contract. See `ligo compile-parameter + --help' for a list of options specific to this subcommand. - Subcommand: evaluate a given definition. - evaluate-value + compile-storage + Subcommand: compile an initial storage in ligo syntax to a + michelson expression. The resulting michelson expression can be + passed as an argument in a transaction which originates a + contract. See `ligo compile-storage --help' for a list of options + specific to this subcommand. - - Subcommand: run a function with the given parameter. - run-function - - - Subcommand: run a smart-contract with the given storage and input. dry-run + Subcommand: run a smart-contract with the given storage and input. + evaluate-value + Subcommand: evaluate a given definition. + + run-function + Subcommand: run a function with the given parameter. OPTIONS --help[=FMT] (default=auto) @@ -57,7 +52,9 @@ let%expect_test _ = run_ligo_good [ "compile-contract" ; "--help" ] ; [%expect {| NAME - ligo-compile-contract + ligo-compile-contract - Subcommand: compile a contract. See `ligo + compile-contract --help' for a list of options specific to this + subcommand. SYNOPSIS ligo compile-contract [OPTION]... SOURCE_FILE ENTRY_POINT @@ -97,7 +94,11 @@ let%expect_test _ = run_ligo_good [ "compile-parameter" ; "--help" ] ; [%expect {| NAME - ligo-compile-parameter + ligo-compile-parameter - Subcommand: compile parameters to a michelson + expression. The resulting michelson expression can be passed as an + argument in a transaction which calls a contract. See `ligo + compile-parameter --help' for a list of options specific to this + subcommand. SYNOPSIS ligo compile-parameter [OPTION]... SOURCE_FILE ENTRY_POINT @@ -141,7 +142,11 @@ let%expect_test _ = run_ligo_good [ "compile-storage" ; "--help" ] ; [%expect {| NAME - ligo-compile-storage + ligo-compile-storage - Subcommand: compile an initial storage in ligo + syntax to a michelson expression. The resulting michelson expression + can be passed as an argument in a transaction which originates a + contract. See `ligo compile-storage --help' for a list of options + specific to this subcommand. SYNOPSIS ligo compile-storage [OPTION]... SOURCE_FILE ENTRY_POINT @@ -185,7 +190,8 @@ let%expect_test _ = run_ligo_good [ "dry-run" ; "--help" ] ; [%expect {| NAME - ligo-dry-run + ligo-dry-run - Subcommand: run a smart-contract with the given storage + and input. SYNOPSIS ligo dry-run [OPTION]... SOURCE_FILE ENTRY_POINT PARAMETER_EXPRESSION @@ -236,7 +242,8 @@ let%expect_test _ = run_ligo_good [ "run-function" ; "--help" ] ; [%expect {| NAME - ligo-run-function + ligo-run-function - Subcommand: run a function with the given + parameter. SYNOPSIS ligo run-function [OPTION]... SOURCE_FILE ENTRY_POINT @@ -284,7 +291,7 @@ let%expect_test _ = run_ligo_good [ "evaluate-value" ; "--help" ] ; [%expect {| NAME - ligo-evaluate-value + ligo-evaluate-value - Subcommand: evaluate a given definition. SYNOPSIS ligo evaluate-value [OPTION]... SOURCE_FILE ENTRY_POINT @@ -328,7 +335,7 @@ let%expect_test _ = run_ligo_good [ "compile-expression" ; "--help" ] ; [%expect {| NAME - ligo-compile-expression + ligo-compile-expression - Subcommand: compile to a michelson value. SYNOPSIS ligo compile-expression [OPTION]... _EXPRESSION From e3fbc58e7ab5936e1c143e2507b3f5d1ebd85bed Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Thu, 21 Nov 2019 11:43:34 -0600 Subject: [PATCH 2/3] Show help instead of "Do ligo --help" --- src/bin/cli.ml | 3 +-- src/bin/expect_tests/help_tests.ml | 43 +++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index 7a9eeba5c..bd3da2499 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -3,8 +3,7 @@ open Trace open Cli_helpers let main = - let term = Term.(const print_endline $ const "Ligo needs a command. Do ligo --help") in - (term , Term.info "ligo") + (Term.(ret (const (`Help (`Auto, None)))) , Term.info "ligo") let source_file n = let open Arg in diff --git a/src/bin/expect_tests/help_tests.ml b/src/bin/expect_tests/help_tests.ml index c740f11ea..35a4c1ec9 100644 --- a/src/bin/expect_tests/help_tests.ml +++ b/src/bin/expect_tests/help_tests.ml @@ -3,7 +3,48 @@ open Cli_expect let%expect_test _ = (* TODO good? *) run_ligo_good [] ; - [%expect {| Ligo needs a command. Do ligo --help |} ] ; + [%expect {| + NAME + ligo + + SYNOPSIS + ligo COMMAND ... + + COMMANDS + compile-contract + Subcommand: compile a contract. See `ligo compile-contract --help' + for a list of options specific to this subcommand. + + compile-expression + Subcommand: compile to a michelson value. + + compile-parameter + Subcommand: compile parameters to a michelson expression. The + resulting michelson expression can be passed as an argument in a + transaction which calls a contract. See `ligo compile-parameter + --help' for a list of options specific to this subcommand. + + compile-storage + Subcommand: compile an initial storage in ligo syntax to a + michelson expression. The resulting michelson expression can be + passed as an argument in a transaction which originates a + contract. See `ligo compile-storage --help' for a list of options + specific to this subcommand. + + dry-run + Subcommand: run a smart-contract with the given storage and input. + + evaluate-value + Subcommand: evaluate a given definition. + + run-function + Subcommand: run a function with the given parameter. + + OPTIONS + --help[=FMT] (default=auto) + Show this help in format FMT. The value FMT must be one of `auto', + `pager', `groff' or `plain'. With `auto', the format is `pager` or + `plain' whenever the TERM env var is `dumb' or undefined. |} ] ; run_ligo_good [ "--help" ] ; [%expect {| From 0040b1f460c9224c43e2510de3ff9b65939e2477 Mon Sep 17 00:00:00 2001 From: Tom Jack Date: Thu, 21 Nov 2019 11:44:27 -0600 Subject: [PATCH 3/3] Mention subcommand --help only once --- src/bin/cli.ml | 11 ++++++---- src/bin/expect_tests/help_tests.ml | 35 +++++++++++++----------------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/bin/cli.ml b/src/bin/cli.ml index bd3da2499..88ffa5307 100644 --- a/src/bin/cli.ml +++ b/src/bin/cli.ml @@ -3,7 +3,10 @@ open Trace open Cli_helpers let main = - (Term.(ret (const (`Help (`Auto, None)))) , Term.info "ligo") + let man = + [ `S "MORE HELP"; + `P "Use `$(mname) $(i,COMMAND) --help' for help on a single command." ] in + (Term.(ret (const (`Help (`Auto, None)))), Term.info "ligo" ~man) let source_file n = let open Arg in @@ -94,7 +97,7 @@ let compile_file = let term = Term.(const f $ source_file 0 $ entry_point 1 $ syntax $ display_format $ michelson_code_format) in let cmdname = "compile-contract" in - let doc = "Subcommand: compile a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in + let doc = "Subcommand: compile a contract." in (term , Term.info ~doc cmdname) let compile_parameter = @@ -108,7 +111,7 @@ let compile_parameter = let term = Term.(const f $ source_file 0 $ entry_point 1 $ expression "PARAMETER" 2 $ syntax $ display_format $ michelson_code_format) in let cmdname = "compile-parameter" in - let doc = "Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which calls a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in + let doc = "Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which calls a contract." in (term , Term.info ~doc cmdname) let compile_storage = @@ -122,7 +125,7 @@ let compile_storage = let term = Term.(const f $ source_file 0 $ entry_point 1 $ expression "STORAGE" 2 $ syntax $ display_format $ michelson_code_format) in let cmdname = "compile-storage" in - let doc = "Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a contract. See `ligo " ^ cmdname ^ " --help' for a list of options specific to this subcommand." in + let doc = "Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a contract." in (term , Term.info ~doc cmdname) let dry_run = diff --git a/src/bin/expect_tests/help_tests.ml b/src/bin/expect_tests/help_tests.ml index 35a4c1ec9..4aecf0190 100644 --- a/src/bin/expect_tests/help_tests.ml +++ b/src/bin/expect_tests/help_tests.ml @@ -10,10 +10,12 @@ let%expect_test _ = SYNOPSIS ligo COMMAND ... + MORE HELP + Use `ligo COMMAND --help' for help on a single command. + COMMANDS compile-contract - Subcommand: compile a contract. See `ligo compile-contract --help' - for a list of options specific to this subcommand. + Subcommand: compile a contract. compile-expression Subcommand: compile to a michelson value. @@ -21,15 +23,13 @@ let%expect_test _ = compile-parameter Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an argument in a - transaction which calls a contract. See `ligo compile-parameter - --help' for a list of options specific to this subcommand. + transaction which calls a contract. compile-storage Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a - contract. See `ligo compile-storage --help' for a list of options - specific to this subcommand. + contract. dry-run Subcommand: run a smart-contract with the given storage and input. @@ -54,10 +54,12 @@ let%expect_test _ = SYNOPSIS ligo COMMAND ... + MORE HELP + Use `ligo COMMAND --help' for help on a single command. + COMMANDS compile-contract - Subcommand: compile a contract. See `ligo compile-contract --help' - for a list of options specific to this subcommand. + Subcommand: compile a contract. compile-expression Subcommand: compile to a michelson value. @@ -65,15 +67,13 @@ let%expect_test _ = compile-parameter Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an argument in a - transaction which calls a contract. See `ligo compile-parameter - --help' for a list of options specific to this subcommand. + transaction which calls a contract. compile-storage Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a - contract. See `ligo compile-storage --help' for a list of options - specific to this subcommand. + contract. dry-run Subcommand: run a smart-contract with the given storage and input. @@ -93,9 +93,7 @@ let%expect_test _ = run_ligo_good [ "compile-contract" ; "--help" ] ; [%expect {| NAME - ligo-compile-contract - Subcommand: compile a contract. See `ligo - compile-contract --help' for a list of options specific to this - subcommand. + ligo-compile-contract - Subcommand: compile a contract. SYNOPSIS ligo compile-contract [OPTION]... SOURCE_FILE ENTRY_POINT @@ -137,9 +135,7 @@ let%expect_test _ = NAME ligo-compile-parameter - Subcommand: compile parameters to a michelson expression. The resulting michelson expression can be passed as an - argument in a transaction which calls a contract. See `ligo - compile-parameter --help' for a list of options specific to this - subcommand. + argument in a transaction which calls a contract. SYNOPSIS ligo compile-parameter [OPTION]... SOURCE_FILE ENTRY_POINT @@ -186,8 +182,7 @@ let%expect_test _ = ligo-compile-storage - Subcommand: compile an initial storage in ligo syntax to a michelson expression. The resulting michelson expression can be passed as an argument in a transaction which originates a - contract. See `ligo compile-storage --help' for a list of options - specific to this subcommand. + contract. SYNOPSIS ligo compile-storage [OPTION]... SOURCE_FILE ENTRY_POINT