Quellcode durchsuchen

add --help to subcommand completions

ensure subcommand exists, then include --help in its completion output
pull/487/head^2
Jason Karns vor 10 Jahren
Ursprung
Commit
d7ca2aba2a
3 geänderte Dateien mit 12 neuen und 2 gelöschten Zeilen
  1. +4
    -0
      libexec/rbenv-completions
  2. +7
    -2
      test/completions.bats
  3. +1
    -0
      test/exec.bats

+ 4
- 0
libexec/rbenv-completions Datei anzeigen

@ -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 "$@"

+ 7
- 2
test/completions.bats Datei anzeigen

@ -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 <<OUT
--help
hello
OUT
}
@test "forwards extra arguments" {
@ -40,6 +44,7 @@ fi"
run rbenv-completions hello happy world
assert_success
assert_output <<OUT
--help
happy
world
OUT

+ 1
- 0
test/exec.bats Datei anzeigen

@ -35,6 +35,7 @@ create_executable() {
run rbenv-completions exec
assert_success
assert_output <<OUT
--help
rake
ruby
OUT

Laden…
Abbrechen
Speichern