From 52d4a937e1f1b6e22b3991c7573b1495f9d7b310 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Wed, 25 Jan 2023 03:31:00 -0800 Subject: [PATCH] feat: All commands print help on `--help` --- lib/commands/command-current.bash | 6 ++++ lib/commands/command-env.bash | 7 ++++- lib/commands/command-exec.bash | 8 ++++- .../command-export-shell-version.bash | 8 ++++- lib/commands/command-help.bash | 5 ++++ lib/commands/command-info.bash | 5 ++++ lib/commands/command-list.bash | 5 ++++ lib/commands/command-plugin-list-all.bash | 5 ++++ lib/commands/command-plugin-remove.bash | 5 ++++ lib/commands/command-shim-versions.bash | 5 ++++ lib/commands/command-uninstall.bash | 6 ++++ lib/commands/command-update.bash | 6 ++++ lib/commands/command-where.bash | 6 ++++ lib/commands/command-which.bash | 8 ++++- lib/commands/reshim.bash | 5 ++++ lib/functions/installs.bash | 8 +++++ lib/functions/plugins.bash | 23 +++++++++++++-- lib/functions/versions.bash | 29 +++++++++++++++---- lib/utils.bash | 12 ++++++++ test/banned_commands.bats | 1 + test/current_command.bats | 6 ++++ test/help_command.bats | 6 ++++ test/info_command.bats | 6 ++++ test/install_command.bats | 6 ++++ test/latest_command.bats | 6 ++++ test/list_command.bats | 12 ++++++++ test/plugin_add_command.bats | 6 ++++ test/plugin_list_all_command.bats | 6 ++++ test/plugin_list_command.bats | 17 +++++++++++ test/plugin_remove_command.bats | 6 ++++ test/plugin_update_command.bats | 6 ++++ test/reshim_command.bats | 6 ++++ test/shim_env_command.bats | 6 ++++ test/shim_exec.bats | 6 ++++ test/shim_versions_command.bats | 6 ++++ test/uninstall_command.bats | 6 ++++ test/update_command.bats | 6 ++++ test/version_commands.bats | 16 ++++++++-- test/where_command.bats | 6 ++++ test/which_command.bats | 6 ++++ 40 files changed, 297 insertions(+), 13 deletions(-) create mode 100644 test/plugin_list_command.bats diff --git a/lib/commands/command-current.bash b/lib/commands/command-current.bash index f4724626e..6dd8b7897 100644 --- a/lib/commands/command-current.bash +++ b/lib/commands/command-current.bash @@ -4,6 +4,12 @@ # shellcheck disable=SC2059 plugin_current_command() { + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf current' + printf '%s\n' 'usage: asdf current ' + exit 0 + fi + local plugin_name=$1 local terminal_format=$2 diff --git a/lib/commands/command-env.bash b/lib/commands/command-env.bash index 30cf7ec4e..de32fafca 100644 --- a/lib/commands/command-env.bash +++ b/lib/commands/command-env.bash @@ -5,8 +5,13 @@ shim_env_command() { local env_cmd="${2}" local env_args=("${@:3}") + local help_text="usage: asdf env " + if has_help_flag "$@"; then + printf '%s\n' "$help_text" + exit 0 + fi if [ -z "$shim_name" ]; then - printf "usage: asdf env \n" + display_error "$help_text" exit 1 fi diff --git a/lib/commands/command-exec.bash b/lib/commands/command-exec.bash index cb56b36c3..f6033140f 100644 --- a/lib/commands/command-exec.bash +++ b/lib/commands/command-exec.bash @@ -1,12 +1,18 @@ # -*- sh -*- shim_exec_command() { + local help_text="usage: asdf exec " + if has_help_flag "$@"; then + printf '%s\n' "$help_text" + exit 0 + fi + local shim_name shim_name=$(basename "$1") local shim_args=("${@:2}") if [ -z "$shim_name" ]; then - printf "usage: asdf exec \n" + display_error "$help_text" exit 1 fi diff --git a/lib/commands/command-export-shell-version.bash b/lib/commands/command-export-shell-version.bash index 13b779d1b..167771902 100644 --- a/lib/commands/command-export-shell-version.bash +++ b/lib/commands/command-export-shell-version.bash @@ -4,11 +4,17 @@ # Output from this command must be executable shell code shell_command() { + local help_text="usage: asdf shell {|--unset}" + if has_help_flag "$@"; then + printf '%s\n' "printf '%s\n' \"$help_text\"" + exit 0 + fi + local asdf_shell="$1" shift if [ "$#" -lt "2" ]; then - printf "Usage: asdf shell {|--unset}\n" >&2 + display_error "$help_text" printf "false\n" exit 1 fi diff --git a/lib/commands/command-help.bash b/lib/commands/command-help.bash index 77f1bb27c..71684bee7 100644 --- a/lib/commands/command-help.bash +++ b/lib/commands/command-help.bash @@ -37,6 +37,11 @@ help_command() { local tool_version="$2" local plugin_path + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf help []' + exit 0 + fi + # If plugin name is present as first argument output plugin help info if [ -n "$plugin_name" ]; then plugin_path=$(get_plugin_path "$plugin_name") diff --git a/lib/commands/command-info.bash b/lib/commands/command-info.bash index 9304ce687..bd4a5b419 100644 --- a/lib/commands/command-info.bash +++ b/lib/commands/command-info.bash @@ -3,6 +3,11 @@ . "$(dirname "$(dirname "$0")")/lib/functions/plugins.bash" info_command() { + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf info' + exit 0 + fi + printf "%s:\n%s\n\n" "OS" "$(uname -a)" printf "%s:\n%s\n\n" "SHELL" "$($SHELL --version)" printf "%s:\n%s\n\n" "ASDF VERSION" "$(asdf_version)" diff --git a/lib/commands/command-list.bash b/lib/commands/command-list.bash index 6cb4cd4b9..1b0e1ecd7 100644 --- a/lib/commands/command-list.bash +++ b/lib/commands/command-list.bash @@ -4,6 +4,11 @@ list_command() { local plugin_name=$1 local query=$2 + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf list [version]' + exit 0 + fi + if [ -z "$plugin_name" ]; then local plugins_path plugins_path=$(get_plugin_path) diff --git a/lib/commands/command-plugin-list-all.bash b/lib/commands/command-plugin-list-all.bash index 33333e59a..d55804c71 100644 --- a/lib/commands/command-plugin-list-all.bash +++ b/lib/commands/command-plugin-list-all.bash @@ -1,6 +1,11 @@ # -*- sh -*- plugin_list_all_command() { + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf plugin list all' + exit 0 + fi + initialize_or_update_repository local plugins_index_path diff --git a/lib/commands/command-plugin-remove.bash b/lib/commands/command-plugin-remove.bash index e4cee0532..cf6d4f54a 100644 --- a/lib/commands/command-plugin-remove.bash +++ b/lib/commands/command-plugin-remove.bash @@ -1,6 +1,11 @@ # -*- sh -*- plugin_remove_command() { + if has_help_flag "$@"; then + printf '%s\n' "usage: asdf plugin remove " + exit 0 + fi + local plugin_name=$1 check_if_plugin_exists "$plugin_name" diff --git a/lib/commands/command-shim-versions.bash b/lib/commands/command-shim-versions.bash index 9a8181a1e..ca70f03b6 100644 --- a/lib/commands/command-shim-versions.bash +++ b/lib/commands/command-shim-versions.bash @@ -1,6 +1,11 @@ # -*- sh -*- shim_versions_command() { + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf shim-versions ' + exit 0 + fi + local shim_name=$1 shim_plugin_versions "$shim_name" } diff --git a/lib/commands/command-uninstall.bash b/lib/commands/command-uninstall.bash index 2e1774f9b..875f3141b 100644 --- a/lib/commands/command-uninstall.bash +++ b/lib/commands/command-uninstall.bash @@ -7,6 +7,12 @@ uninstall_command() { local plugin_name=$1 local full_version=$2 local plugin_path + + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf uninstall ' + exit 0 + fi + plugin_path=$(get_plugin_path "$plugin_name") check_if_plugin_exists "$plugin_name" diff --git a/lib/commands/command-update.bash b/lib/commands/command-update.bash index f9912645f..c4adb7031 100644 --- a/lib/commands/command-update.bash +++ b/lib/commands/command-update.bash @@ -3,6 +3,12 @@ update_command() { local update_to_head=$1 + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf update' + printf '%s\n' 'usage: asdf update --head' + exit 0 + fi + ( cd "$(asdf_dir)" || exit 1 diff --git a/lib/commands/command-where.bash b/lib/commands/command-where.bash index d2b9d0396..a0165adc3 100644 --- a/lib/commands/command-where.bash +++ b/lib/commands/command-where.bash @@ -3,6 +3,12 @@ where_command() { local plugin_name=$1 local full_version=$2 + + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf where []' + exit 0 + fi + check_if_plugin_exists "$plugin_name" local version diff --git a/lib/commands/command-which.bash b/lib/commands/command-which.bash index 8696dbf3e..2d78243d6 100644 --- a/lib/commands/command-which.bash +++ b/lib/commands/command-which.bash @@ -1,11 +1,17 @@ # -*- sh -*- which_command() { + local help_text="usage: asdf which " + if has_help_flag "$@"; then + printf '%s\n' "$help_text" + exit 0 + fi + local shim_name shim_name=$(basename "$1") if [ -z "$shim_name" ]; then - printf "usage: asdf which \n" + display_error "$help_text" exit 1 fi diff --git a/lib/commands/reshim.bash b/lib/commands/reshim.bash index 8a703a4d2..5f4c0d46c 100644 --- a/lib/commands/reshim.bash +++ b/lib/commands/reshim.bash @@ -28,6 +28,11 @@ reshim_command() { local plugin_name=$1 local full_version=$2 + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf reshim ' + exit 0 + fi + if [ -z "$plugin_name" ]; then local plugins_path plugins_path=$(get_plugin_path) diff --git a/lib/functions/installs.bash b/lib/functions/installs.bash index 9f85c652c..005f663d6 100644 --- a/lib/functions/installs.bash +++ b/lib/functions/installs.bash @@ -15,6 +15,14 @@ install_command() { local full_version=$2 local extra_args="${*:3}" + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf install' + printf '%s\n' 'usage: asdf install ' + printf '%s\n' 'usage: asdf install ' + printf '%s\n' 'usage: asdf install latest[:]' + exit 0 + fi + if [ "$plugin_name" = "" ] && [ "$full_version" = "" ]; then install_local_tool_versions "$extra_args" elif [[ $# -eq 1 ]]; then diff --git a/lib/functions/plugins.bash b/lib/functions/plugins.bash index 18d50af11..2d1b5c2b4 100644 --- a/lib/functions/plugins.bash +++ b/lib/functions/plugins.bash @@ -1,4 +1,10 @@ plugin_list_command() { + if has_help_flag "$@"; then + printf '%s\n' "usage: asdf plugin list [--urls] [--refs]" + printf '%s\n' "usage: asdf plugin list all" + exit 0 + fi + local plugins_path plugins_path=$(get_plugin_path) @@ -49,8 +55,13 @@ plugin_list_command() { } plugin_add_command() { + local help_text="usage: asdf plugin add []" + if has_help_flag "$@"; then + printf '%s\n' "$help_text" + exit 0 + fi if [[ $# -lt 1 || $# -gt 2 ]]; then - display_error "usage: asdf plugin add []" + display_error "$help_text" exit 1 fi @@ -106,8 +117,16 @@ plugin_add_command() { } plugin_update_command() { + local help_text1="usage: asdf plugin-update [git-ref]" + local help_text2="usage: asdf plugin-update --all" + if has_help_flag "$@"; then + printf '%s\n' "$help_text1" + printf '%s\n' "$help_text2" + exit 0 + fi if [ "$#" -lt 1 ]; then - display_error "usage: asdf plugin-update { [git-ref] | --all}" + display_error "$help_text1" + display_error "$help_text2" exit 1 fi diff --git a/lib/functions/versions.bash b/lib/functions/versions.bash index 28262f78e..dae21b72e 100644 --- a/lib/functions/versions.bash +++ b/lib/functions/versions.bash @@ -2,13 +2,20 @@ version_command() { local cmd=$1 local plugin_name=$2 - if [ "$#" -lt "3" ]; then - if [ "$cmd" = "global" ]; then - printf "Usage: asdf global \n" + if has_help_flag "$@" || [ "$#" -lt "3" ]; then + if [ "$cmd" = 'global' ]; then + printf '%s\n' "usage: asdf global " + printf '%s\n' "usage: asdf global latest[:]" else - printf "Usage: asdf local \n" + printf '%s\n' "usage: asdf local " + printf '%s\n' "usage: asdf local latest[:]" + fi + + if has_help_flag "$@"; then + exit 0 + else + exit 1 fi - exit 1 fi shift 2 @@ -79,6 +86,12 @@ list_all_command() { local std_out_file local std_err_file local output + + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf list all []' + exit 0 + fi + plugin_path=$(get_plugin_path "$plugin_name") check_if_plugin_exists "$plugin_name" @@ -129,6 +142,12 @@ latest_command() { local query=$2 local plugin_path + if has_help_flag "$@"; then + printf '%s\n' 'usage: asdf latest []' + printf '%s\n' 'usage: asdf latest --all' + exit 0 + fi + if [ "$plugin_name" = "--all" ]; then latest_all fi diff --git a/lib/utils.bash b/lib/utils.bash index cecfdec6c..b37834348 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -860,3 +860,15 @@ util_resolve_user_path() { util_resolve_user_path_reply="$path" fi } + +# @description Returns true if any arguments is '-h' or '--help' +has_help_flag() { + local arg= + for arg in "$@"; do + case $arg in + -h | --help) return 0 ;; + esac + done + + return 1 +} diff --git a/test/banned_commands.bats b/test/banned_commands.bats index b947e1895..776866a0a 100644 --- a/test/banned_commands.bats +++ b/test/banned_commands.bats @@ -87,6 +87,7 @@ teardown() { | grep -v '#.*$cmd'\ | grep -v '\".*$cmd.*\"' \ | grep -v '${cmd}_'\ + | grep -v 'usage: asdf'\ | grep -v '# asdf_allow: $cmd'" # Only print output if we've found a banned command diff --git a/test/current_command.bats b/test/current_command.bats index b32db8758..bca965190 100755 --- a/test/current_command.bats +++ b/test/current_command.bats @@ -142,3 +142,9 @@ foobar 1.0.0 $PROJECT_DIR/.tool-versions" [ "$status" -eq 0 ] [ "$output" = "$expected" ] } + +@test "current prints help if --help is passed" { + run asdf current --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/help_command.bats b/test/help_command.bats index 9124cfb1f..512a4b221 100644 --- a/test/help_command.bats +++ b/test/help_command.bats @@ -75,3 +75,9 @@ EOF [ "$status" -eq 0 ] # TODO: Assert asdf help output is printed } + +@test "help prints help if --help is passed" { + run asdf help --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/info_command.bats b/test/info_command.bats index 57e69dec6..76243a612 100644 --- a/test/info_command.bats +++ b/test/info_command.bats @@ -25,3 +25,9 @@ teardown() { [ "$status" -eq 0 ] # TODO: Assert asdf info output is printed } + +@test "info prints help if --help is passed" { + run asdf info --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/install_command.bats b/test/install_command.bats index 7cf6f29c1..c8e372de4 100644 --- a/test/install_command.bats +++ b/test/install_command.bats @@ -283,3 +283,9 @@ EOM [ ! -d "$ASDF_DIR/installs/dummy-broken/1.1.0" ] [ "$output" = "Download failed!" ] } + +@test "install_command prints help if --help is passed" { + run asdf install --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/latest_command.bats b/test/latest_command.bats index d46a8cb6c..564f625b3 100644 --- a/test/latest_command.bats +++ b/test/latest_command.bats @@ -12,6 +12,12 @@ teardown() { clean_asdf_dir } +@test "[laetst_command] prints help if --help is passed" { + run asdf latest --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} + #################################################### #### plugin with bin/latest-stable #### #################################################### diff --git a/test/list_command.bats b/test/list_command.bats index 26f7938d6..7b850becd 100644 --- a/test/list_command.bats +++ b/test/list_command.bats @@ -75,6 +75,12 @@ teardown() { [ "$status" -eq 1 ] } +@test "list_command prints help if --help is passed" { + run asdf list --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} + @test "list_all_command lists available versions" { run asdf list-all dummy [ "$(echo -e "1.0.0\n1.1.0\n2.0.0")" = "$output" ] @@ -109,3 +115,9 @@ teardown() { run asdf list-all dummy [[ "$output" != *"ignore this error"* ]] } + +@test "list_all_command prints help if --help is passed" { + run asdf list-all --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/plugin_add_command.bats b/test/plugin_add_command.bats index 78bf845c3..d4f696470 100644 --- a/test/plugin_add_command.bats +++ b/test/plugin_add_command.bats @@ -173,3 +173,9 @@ EOM ADD" [ "$output" = "${expected_output}" ] } + +@test "plugin_add prints help if --help is passed" { + run asdf plugin add --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/plugin_list_all_command.bats b/test/plugin_list_all_command.bats index 478e01fa5..72b1cd1be 100644 --- a/test/plugin_list_all_command.bats +++ b/test/plugin_list_all_command.bats @@ -73,3 +73,9 @@ foo http://example.com/foo" [ "$status" -eq 0 ] [ "$output" = "$expected" ] } + +@test "plugin_list_all prints help if --help is passed" { + run asdf plugin list all --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/plugin_list_command.bats b/test/plugin_list_command.bats new file mode 100644 index 000000000..9ac58e58c --- /dev/null +++ b/test/plugin_list_command.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats + +load test_helpers + +setup() { + setup_asdf_dir +} + +teardown() { + clean_asdf_dir +} + +@test "plugin_list_command prints help if --help is passed" { + run asdf plugin list --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/plugin_remove_command.bats b/test/plugin_remove_command.bats index 911ec374e..8d71ecbfa 100644 --- a/test/plugin_remove_command.bats +++ b/test/plugin_remove_command.bats @@ -26,3 +26,9 @@ teardown() { [ "$status" -eq 1 ] echo "$output" | grep "No such plugin: does-not-exist" } + +@test "plugin_remove prints help if --help is passed" { + run asdf plugin remove --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/plugin_update_command.bats b/test/plugin_update_command.bats index e8ce1b0fa..1a59411b9 100644 --- a/test/plugin_update_command.bats +++ b/test/plugin_update_command.bats @@ -221,3 +221,9 @@ EOM UPDATE" [[ "$output" = *"${expected_output}" ]] } + +@test "asdf plugin-update prints help if --help is passed" { + run asdf plugin update --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/reshim_command.bats b/test/reshim_command.bats index 406c072db..ef7ae7cda 100644 --- a/test/reshim_command.bats +++ b/test/reshim_command.bats @@ -156,3 +156,9 @@ EOM run grep -v 'borked_path_due_to_homebrew_update' "$dummy_shim" [ "$status" -eq 0 ] } + +@test "reshim prints help if --help is passed" { + run asdf reshim --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/shim_env_command.bats b/test/shim_env_command.bats index 8e316da67..cd735d056 100644 --- a/test/shim_env_command.bats +++ b/test/shim_env_command.bats @@ -81,3 +81,9 @@ teardown() { run grep '::' <(echo "$path_line") [ "$duplicate_colon" = "" ] } + +@test "asdf env prints help if --help is passed" { + run asdf env --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/shim_exec.bats b/test/shim_exec.bats index f9b133660..b8b435d6d 100644 --- a/test/shim_exec.bats +++ b/test/shim_exec.bats @@ -446,3 +446,9 @@ EOM [ "$output" = "This is Dummy 1.0! hello world" ] [ "$status" -eq 0 ] } + +@test "asdf exec prints help if --help is passed" { + run asdf exec --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/shim_versions_command.bats b/test/shim_versions_command.bats index e4ed706c1..4fe70b0a2 100644 --- a/test/shim_versions_command.bats +++ b/test/shim_versions_command.bats @@ -27,3 +27,9 @@ teardown() { echo "$output" | grep "dummy 3.0" echo "$output" | grep "dummy 1.0" } + +@test "shim_versions_command prints help if --help is passed" { + run asdf shim-versions --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/uninstall_command.bats b/test/uninstall_command.bats index a55134682..20774b1af 100644 --- a/test/uninstall_command.bats +++ b/test/uninstall_command.bats @@ -102,3 +102,9 @@ EOM run asdf uninstall dummy 1.0.0 [ "$output" = "removed dummy 1.0.0" ] } + +@test "uninstall command prints help if --help is passed" { + run asdf uninstall --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/update_command.bats b/test/update_command.bats index 13c259fe0..ee1ac649f 100644 --- a/test/update_command.bats +++ b/test/update_command.bats @@ -111,3 +111,9 @@ teardown() { [ "$status" -eq 0 ] [ -f "$ASDF_DIR/shims/dummy" ] } + +@test "asdf update prints help if --help is passed" { + run asdf update --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/version_commands.bats b/test/version_commands.bats index a6ecc40a7..152de5170 100644 --- a/test/version_commands.bats +++ b/test/version_commands.bats @@ -35,7 +35,13 @@ teardown() { @test "local should emit an error when called with incorrect arity" { run asdf local "dummy" [ "$status" -eq 1 ] - [ "$output" = "Usage: asdf local " ] + [[ "$output" == "usage: "* ]] +} + +@test "local prints help if --help is passed" { + run asdf local --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] } @test "local should emit an error when plugin does not exist" { @@ -158,7 +164,7 @@ teardown() { @test "local -p/--parent should set should emit an error when called with incorrect arity" { run asdf local -p "dummy" [ "$status" -eq 1 ] - [ "$output" = "Usage: asdf local " ] + [[ "$output" == "usage: "* ]] } @test "local -p/--parent should emit an error when plugin does not exist" { @@ -203,6 +209,12 @@ teardown() { [ "$(cat "$HOME/.tool-versions")" = "dummy 1.1.0" ] } +@test "global prints help if --help is passed" { + run asdf global --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} + @test "[global - dummy_plugin] with latest should use the latest installed version" { run asdf global "dummy" "latest" [ "$status" -eq 0 ] diff --git a/test/where_command.bats b/test/where_command.bats index ddb2c32b0..7c781ea91 100644 --- a/test/where_command.bats +++ b/test/where_command.bats @@ -69,3 +69,9 @@ function teardown() { [ "$status" -eq 1 ] [ "$output" = "$expected" ] } + +@test "where prints help if --help is passed" { + run asdf where --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +} diff --git a/test/which_command.bats b/test/which_command.bats index 3dc708a91..8d7ee4a95 100644 --- a/test/which_command.bats +++ b/test/which_command.bats @@ -106,3 +106,9 @@ teardown() { [ "$status" -eq 1 ] [ "$output" = "No dummy executable found for dummy 1.0" ] } + +@test "which prints help if --help is passed" { + run asdf which --help + [ "$status" -eq 0 ] + [[ "${lines[0]}" == 'usage: '* ]] +}