From d7ca2aba2ac0c986b0232a9592a33da2823bc81d Mon Sep 17 00:00:00 2001 From: Jason Karns Date: Tue, 17 Nov 2015 15:01:33 -0500 Subject: [PATCH] add --help to subcommand completions ensure subcommand exists, then include --help in its completion output --- libexec/rbenv-completions | 4 ++++ test/completions.bats | 9 +++++++-- test/exec.bats | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libexec/rbenv-completions b/libexec/rbenv-completions index 196212e..4cb020c 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 9091f08..6871cf5 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 <