diff --git a/libexec/rbenv b/libexec/rbenv index 609eda11..a7c4cc5a 100755 --- a/libexec/rbenv +++ b/libexec/rbenv @@ -97,7 +97,7 @@ case "$command" in } >&2 exit 1 ;; --v ) +-v | --version ) exec rbenv---version ;; -h | --help ) @@ -111,6 +111,10 @@ case "$command" in fi shift 1 - exec "$command_path" "$@" + if [ "$1" = --help ]; then + exec rbenv-help "$command" + else + exec "$command_path" "$@" + fi ;; esac diff --git a/libexec/rbenv-completions b/libexec/rbenv-completions index 196212e4..4cb020cf 100755 --- a/libexec/rbenv-completions +++ b/libexec/rbenv-completions @@ -11,6 +11,10 @@ if [ -z "$COMMAND" ]; then fi COMMAND_PATH="$(command -v "rbenv-$COMMAND" || command -v "rbenv-sh-$COMMAND")" + +# --help is provided automatically +echo --help + if grep -iE "^([#%]|--|//) provide rbenv completions" "$COMMAND_PATH" >/dev/null; then shift exec "$COMMAND_PATH" --complete "$@" diff --git a/test/completions.bats b/test/completions.bats index 9091f082..6871cf5e 100644 --- a/test/completions.bats +++ b/test/completions.bats @@ -13,7 +13,7 @@ create_command() { create_command "rbenv-hello" "#!$BASH echo hello" run rbenv-completions hello - assert_success "" + assert_success "--help" } @test "command with completion support" { @@ -25,7 +25,11 @@ else exit 1 fi" run rbenv-completions hello - assert_success "hello" + assert_success + assert_output <