Skip to content

Commit 0dcedef

Browse files
committed
Fix completion for bundle config
1 parent cb3f942 commit 0dcedef

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

completion-bundle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ __bundle() {
8181
;;
8282
config)
8383
case $prev in
84-
config | --*)
84+
config | get | set | unset | --*)
8585
case $cur in
8686
local.*)
8787
options=($(__bundle_exec_ruby 'puts Bundler.definition.specs.to_hash.keys'))
@@ -100,17 +100,19 @@ __bundle() {
100100
no_install no_prune only_update_to_newer_versions
101101
plugins shebang silence_root_warning
102102
ssl_verify_mode system_bindir user_agent)
103+
if [[ $prev = config ]]; then
104+
options+=(get set unset)
105+
fi
103106
# We want to suggest the options above as complete words,
104107
# and also "local." and "mirror." as prefixes
105108
# To achieve that, disable automatic space insertion,
106109
# insert it manually, then add the non-spaced prefixes
107110
compopt -o nospace 2>/dev/null
108-
options=("${options[@]/%/ }")
109-
# And add prefix suggestions
110-
options+=(local. mirror.)
111-
# Override $IFS for completion to work
112111
local IFS=$'\n'
113-
COMPREPLY=($(compgen -W '${options[@]}' -- "$cur"))
112+
COMPREPLY=($(compgen -W "${options[*]}" -S ' ' -- "$cur"))
113+
# And add prefix suggestions
114+
options=(local. mirror.)
115+
COMPREPLY+=($(compgen -W "${options[*]}" -- "$cur"))
114116
return
115117
;;
116118
esac

tests/completion-bundle/test.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,29 @@ begin-test 'should offer global options'
2626
)
2727
end-test
2828

29+
begin-test 'should offer configurations with trailing spaces for: bundle config'
30+
(
31+
test-completion bundle config ''
32+
expect 'path ' 'frozen ' 'without ' local.
33+
reject install rake 'local. '
34+
)
35+
end-test
36+
37+
begin-test 'should offer configurations with trailing spaces for: bundle config get'
38+
(
39+
test-completion bundle config get c
40+
expect 'cache_all_platforms ' 'cache_all ' 'clean ' 'console '
41+
)
42+
end-test
43+
44+
begin-test 'should offer local gems for: bundle config get local.*'
45+
(
46+
test-completion bundle config get local.
47+
expect local.rake
48+
reject local.cache_all_platforms
49+
)
50+
end-test
51+
2952
begin-test 'should trigger completion for subcommands: rake'
3053
(
3154
test-completion bundle exec rake ''

0 commit comments

Comments
 (0)