diff --git a/src/bin_agnostic_baker/main_agnostic_baker.ml b/src/bin_agnostic_baker/main_agnostic_baker.ml index 8012ba1a22523699925b7067456b160958a08f14..d3928cddb25b70466baf35cd549948b0abfc208e 100644 --- a/src/bin_agnostic_baker/main_agnostic_baker.ml +++ b/src/bin_agnostic_baker/main_agnostic_baker.ml @@ -62,7 +62,11 @@ let run ~args () = let () = let args = Array.to_list Sys.argv in - if Run_args.(is_help_cmd args || is_version_cmd args || is_man_cmd args) then + if + Run_args.( + only_exe args || is_help_cmd args || is_version_cmd args + || is_man_cmd args) + then (* No need to run the baker commands, we just need to get their description, therefore we do not obtain the protocol plugin. *) Client_main_run.run diff --git a/src/lib_agnostic_baker/run_args.ml b/src/lib_agnostic_baker/run_args.ml index c9e53a8298319a257e38b0d2ea979f8c867333a8..e00333e56a6298fbfc847a1185d327119abf2d80 100644 --- a/src/lib_agnostic_baker/run_args.ml +++ b/src/lib_agnostic_baker/run_args.ml @@ -14,6 +14,8 @@ let version_arg = "--version" let man_arg = "man" +let only_exe args = List.compare_length_with args 1 = 0 + let is_help_cmd = List.mem ~equal:String.equal help_arg let is_version_cmd = List.mem ~equal:String.equal version_arg diff --git a/src/lib_agnostic_baker/run_args.mli b/src/lib_agnostic_baker/run_args.mli index 73cb30d6d98cf1bbc7eec7d74434185d630375cc..088f22b1320be4f058834228b396359aa142af23 100644 --- a/src/lib_agnostic_baker/run_args.mli +++ b/src/lib_agnostic_baker/run_args.mli @@ -6,6 +6,9 @@ (* *) (*****************************************************************************) +(** [only_exe args] returns [true] iff [args] only contains one argument, which is the executable. *) +val only_exe : string list -> bool + (** [is_help_cmd args] returns [true] iff [--help] is amongst [args]. *) val is_help_cmd : string list -> bool diff --git a/tezt/tests/agnostic_baker_test.ml b/tezt/tests/agnostic_baker_test.ml index 0d7504b663583f322ad0d3f1f36e04c1be2f55c3..42a8fe18ac621aa6104d096c1825e7c6dab104f7 100644 --- a/tezt/tests/agnostic_baker_test.ml +++ b/tezt/tests/agnostic_baker_test.ml @@ -171,14 +171,7 @@ let migrate ~migrate_from ~migrate_to ~use_remote_signer = in unit -let register ~migrate_from ~migrate_to = - (* We want to migrate only from Active protocols *) - if Agnostic_baker.protocol_status migrate_from = Active then ( - migrate ~migrate_from ~migrate_to ~use_remote_signer:false ; - migrate ~migrate_from ~migrate_to ~use_remote_signer:true) - else () - -let register_protocol_independent () = +let test_start_and_stop () = Test.register ~__FILE__ ~title:"Agnostic baker starts and stops" @@ -190,3 +183,34 @@ let register_protocol_independent () = let* () = Agnostic_baker.wait_for_ready baker in let* () = Agnostic_baker.terminate baker in unit + +let test_man () = + Regression.register + ~__FILE__ + ~title:"Agnostic baker man" + ~tags:[team; "sandbox"; "agnostic"; "baker"; "man"] + ~uses:[Constant.octez_agnostic_baker] + ~uses_node:false + ~uses_client:false + ~uses_admin_client:false + @@ fun () -> + let hooks = Tezos_regression.hooks in + let* () = Process.run ~hooks (Uses.path Constant.octez_agnostic_baker) [] in + let* () = + Process.run ~hooks (Uses.path Constant.octez_agnostic_baker) ["--help"] + in + let* () = + Process.run ~hooks (Uses.path Constant.octez_agnostic_baker) ["man"] + in + unit + +let register ~migrate_from ~migrate_to = + (* We want to migrate only from Active protocols *) + if Agnostic_baker.protocol_status migrate_from = Active then ( + migrate ~migrate_from ~migrate_to ~use_remote_signer:false ; + migrate ~migrate_from ~migrate_to ~use_remote_signer:true) + else () + +let register_protocol_independent () = + test_start_and_stop () ; + test_man () diff --git a/tezt/tests/expected/agnostic_baker_test.ml/Agnostic baker man.out b/tezt/tests/expected/agnostic_baker_test.ml/Agnostic baker man.out new file mode 100644 index 0000000000000000000000000000000000000000..894cab99c974a0a82027b60e24482dff2023c124 --- /dev/null +++ b/tezt/tests/expected/agnostic_baker_test.ml/Agnostic baker man.out @@ -0,0 +1,192 @@ + +./octez-agnostic-baker +Usage: + octez-agnostic-baker [global options] command [command options] + octez-agnostic-baker --help (for global options) + octez-agnostic-baker [global options] command --help (for command options) + octez-agnostic-baker --version (for version information) + +To browse the documentation: + octez-agnostic-baker [global options] man (for a list of commands) + octez-agnostic-baker [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands + dependent on the context associated with the specified chain). Possible + tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands + (commands dependent on the context associated with the specified block). + Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. + "octez-client -b head-1 get timestamp"). Note that block queried must + exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an + operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to + an RPC fails or if you don't know the input accepted by the RPC. It may + happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address + of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the + node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value + for the "accept" header for RPC requests to the node. The media accept + header indicates to the node which format of data serialisation is + supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. + 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. + Example file content: {"min_agreement": 1.0, "uris": + ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the + node + --log-coloring : Enable or disable light coloring in default + stdout logs. Coloring is enabled by default. + +./octez-agnostic-baker --help +Usage: + octez-agnostic-baker [global options] command [command options] + octez-agnostic-baker --help (for global options) + octez-agnostic-baker [global options] command --help (for command options) + octez-agnostic-baker --version (for version information) + +To browse the documentation: + octez-agnostic-baker [global options] man (for a list of commands) + octez-agnostic-baker [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands + dependent on the context associated with the specified chain). Possible + tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands + (commands dependent on the context associated with the specified block). + Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. + "octez-client -b head-1 get timestamp"). Note that block queried must + exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an + operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to + an RPC fails or if you don't know the input accepted by the RPC. It may + happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address + of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the + node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value + for the "accept" header for RPC requests to the node. The media accept + header indicates to the node which format of data serialisation is + supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. + 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. + Example file content: {"min_agreement": 1.0, "uris": + ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the + node + --log-coloring : Enable or disable light coloring in default + stdout logs. Coloring is enabled by default. + +./octez-agnostic-baker man +Usage: + octez-agnostic-baker [global options] command [command options] + octez-agnostic-baker --help (for global options) + octez-agnostic-baker [global options] command --help (for command options) + octez-agnostic-baker --version (for version information) + +To browse the documentation: + octez-agnostic-baker [global options] man (for a list of commands) + octez-agnostic-baker [global options] man -v 3 (for the full manual) + +Global options (must come before the command): + -d --base-dir : client data directory (absent: TEZOS_CLIENT_DIR env) + -n --no-base-dir-warnings: silence warnings about client data directory + -c --config-file : configuration file + -t --timings: show RPC request times + --chain : chain on which to apply contextual commands (commands + dependent on the context associated with the specified chain). Possible + tags are 'main' and 'test'. + -b --block : block on which to apply contextual commands + (commands dependent on the context associated with the specified block). + Possible tags include 'head' and 'genesis' +/- an optional offset (e.g. + "octez-client -b head-1 get timestamp"). Note that block queried must + exist in node's storage. + -w --wait >: how many confirmation blocks are needed before an + operation is considered included + -p --protocol : use commands of a specific protocol + -l --log-requests: log all requests to the node + --better-errors: Error reporting is more detailed. Can be used if a call to + an RPC fails or if you don't know the input accepted by the RPC. It may + happen that the RPC calls take more time however. + -A --addr : [DEPRECATED: use --endpoint instead] IP address + of the node + -P --port : [DEPRECATED: use --endpoint instead] RPC port of the + node + -S --tls: [DEPRECATED: use --endpoint instead] use TLS to connect to node. + -m --media-type : Sets the "media-type" value + for the "accept" header for RPC requests to the node. The media accept + header indicates to the node which format of data serialisation is + supported. Use the value "json" for serialisation to the JSON format. + -E --endpoint : HTTP(S) endpoint of the node RPC interface; e.g. + 'http://localhost:8732' + -s --sources : path to JSON file containing sources for --mode light. + Example file content: {"min_agreement": 1.0, "uris": + ["http://localhost:8732", "https://localhost:8733"]} + -R --remote-signer : URI of the remote signer + -f --password-filename : path to the password filename + -M --mode : how to interact with the + node + --log-coloring : Enable or disable light coloring in default + stdout logs. Coloring is enabled by default. + +Access the documentation: + + man [...] + Print documentation of commands. + +Commands for editing and viewing the client's config file: + + config show + Show the current config (config file content + command line arguments) or + the mockup config files if `--mode mockup` is specified. + + config reset + Reset the config file to the factory defaults. + + config update + Update the config based on the current cli values. + + config init + Create config file(s) based on the current CLI values. + +Commands related to the agnostic baker daemon.: + + run with local node [...] + Launch the baker daemon. + + run remotely [...] + Launch the baker daemon using RPCs only. + + run vdf + Launch the VDF daemon + +Miscellaneous commands: + + list understood protocols + List the protocol versions that this client understands.