mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Merge pull request #824 from jasonkarns/help-completion
Handle --help flag for subcommands
This commit is contained in:
commit
63671a1479
4 changed files with 18 additions and 4 deletions
|
@ -97,7 +97,7 @@ case "$command" in
|
||||||
} >&2
|
} >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
-v )
|
-v | --version )
|
||||||
exec rbenv---version
|
exec rbenv---version
|
||||||
;;
|
;;
|
||||||
-h | --help )
|
-h | --help )
|
||||||
|
@ -111,6 +111,10 @@ case "$command" in
|
||||||
fi
|
fi
|
||||||
|
|
||||||
shift 1
|
shift 1
|
||||||
|
if [ "$1" = --help ]; then
|
||||||
|
exec rbenv-help "$command"
|
||||||
|
else
|
||||||
exec "$command_path" "$@"
|
exec "$command_path" "$@"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -11,6 +11,10 @@ if [ -z "$COMMAND" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
COMMAND_PATH="$(command -v "rbenv-$COMMAND" || command -v "rbenv-sh-$COMMAND")"
|
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
|
if grep -iE "^([#%]|--|//) provide rbenv completions" "$COMMAND_PATH" >/dev/null; then
|
||||||
shift
|
shift
|
||||||
exec "$COMMAND_PATH" --complete "$@"
|
exec "$COMMAND_PATH" --complete "$@"
|
||||||
|
|
|
@ -13,7 +13,7 @@ create_command() {
|
||||||
create_command "rbenv-hello" "#!$BASH
|
create_command "rbenv-hello" "#!$BASH
|
||||||
echo hello"
|
echo hello"
|
||||||
run rbenv-completions hello
|
run rbenv-completions hello
|
||||||
assert_success ""
|
assert_success "--help"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "command with completion support" {
|
@test "command with completion support" {
|
||||||
|
@ -25,7 +25,11 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi"
|
fi"
|
||||||
run rbenv-completions hello
|
run rbenv-completions hello
|
||||||
assert_success "hello"
|
assert_success
|
||||||
|
assert_output <<OUT
|
||||||
|
--help
|
||||||
|
hello
|
||||||
|
OUT
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "forwards extra arguments" {
|
@test "forwards extra arguments" {
|
||||||
|
@ -40,6 +44,7 @@ fi"
|
||||||
run rbenv-completions hello happy world
|
run rbenv-completions hello happy world
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
|
--help
|
||||||
happy
|
happy
|
||||||
world
|
world
|
||||||
OUT
|
OUT
|
||||||
|
|
|
@ -35,6 +35,7 @@ create_executable() {
|
||||||
run rbenv-completions exec
|
run rbenv-completions exec
|
||||||
assert_success
|
assert_success
|
||||||
assert_output <<OUT
|
assert_output <<OUT
|
||||||
|
--help
|
||||||
rake
|
rake
|
||||||
ruby
|
ruby
|
||||||
OUT
|
OUT
|
||||||
|
|
Loading…
Reference in a new issue