Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/completely/templates/template.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
% patterns.each do |pattern|
% next if pattern.empty?
<%= pattern.case_string %>)
COMPREPLY=($(compgen <%= pattern.compgen %> -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen <%= pattern.compgen %> -- "$cur" )
;;

% end
Expand Down
5 changes: 4 additions & 1 deletion lib/completely/templates/tester-template.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ COMP_POINT=${#COMP_LINE}
COMP_CWORD=<%= cword %>

<%= function_name %>
echo "${COMPREPLY[*]}"
for suggestion in "${COMPREPLY[@]}"; do
echo "$suggestion"
done

2 changes: 1 addition & 1 deletion lib/completely/tester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test(compline)
f << tester_script(compline)
f.flush
`bash #{f.path}`
end.split " "
end.split "\n"
end

def tester_script(compline)
Expand Down
8 changes: 4 additions & 4 deletions spec/approvals/cli/generated-script
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ _mygit_completions() {

case "$compline" in
'status'*)
COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )
;;

'commit'*)
COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )
;;

'init'*)
COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )
;;

*)
COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )
;;

esac
Expand Down
8 changes: 4 additions & 4 deletions spec/approvals/cli/generated-script-alt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ _mycomps() {

case "$compline" in
'status'*)
COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )
;;

'commit'*)
COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )
;;

'init'*)
COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )
;;

*)
COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )
;;

esac
Expand Down
8 changes: 4 additions & 4 deletions spec/approvals/cli/generated-wrapped-script
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ give_comps() {
echo $''
echo $' case "$compline" in'
echo $' \'status\'*)'
echo $' COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))'
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )'
echo $' ;;'
echo $''
echo $' \'commit\'*)'
echo $' COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))'
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )'
echo $' ;;'
echo $''
echo $' \'init\'*)'
echo $' COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))'
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )'
echo $' ;;'
echo $''
echo $' *)'
echo $' COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))'
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )'
echo $' ;;'
echo $''
echo $' esac'
Expand Down
13 changes: 8 additions & 5 deletions spec/approvals/cli/test/completely-tester.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ _mygit_completions() {

case "$compline" in
'status'*)
COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur" )
;;

'commit'*)
COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur" )
;;

'init'*)
COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--bare" -- "$cur" )
;;

*)
COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version status init commit" -- "$cur" )
;;

esac
Expand All @@ -48,4 +48,7 @@ COMP_POINT=${#COMP_LINE}
COMP_CWORD=2

_mygit_completions
echo "${COMPREPLY[*]}"
for suggestion in "${COMPREPLY[@]}"; do
echo "$suggestion"
done

6 changes: 3 additions & 3 deletions spec/approvals/completions/function
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ send_completions() {
echo $''
echo $' case "$compline" in'
echo $' \'generate\'*)'
echo $' COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur"))'
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--help --force" -- "$cur" )'
echo $' ;;'
echo $''
echo $' \'init\'*)'
echo $' COMPREPLY=($(compgen -W "--help" -- "$cur"))'
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help" -- "$cur" )'
echo $' ;;'
echo $''
echo $' *)'
echo $' COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur"))'
echo $' while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version init generate" -- "$cur" )'
echo $' ;;'
echo $''
echo $' esac'
Expand Down
6 changes: 3 additions & 3 deletions spec/approvals/completions/script
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ _completely_completions() {

case "$compline" in
'generate'*)
COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--help --force" -- "$cur" )
;;

'init'*)
COMPREPLY=($(compgen -W "--help" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help" -- "$cur" )
;;

*)
COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version init generate" -- "$cur" )
;;

esac
Expand Down
4 changes: 2 additions & 2 deletions spec/approvals/completions/script-only-spaces
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ _completely_completions() {

case "$compline" in
'generate'*)
COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -A directory -W "--help --force" -- "$cur" )
;;

'init'*)
COMPREPLY=($(compgen -W "--help" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help" -- "$cur" )
;;

esac
Expand Down
5 changes: 4 additions & 1 deletion spec/approvals/tester/script
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ COMP_POINT=${#COMP_LINE}
COMP_CWORD=1

_cli_completions
echo "${COMPREPLY[*]}"
for suggestion in "${COMPREPLY[@]}"; do
echo "$suggestion"
done

5 changes: 4 additions & 1 deletion spec/approvals/tester/script_path
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ COMP_POINT=${#COMP_LINE}
COMP_CWORD=1

_cli_completions
echo "${COMPREPLY[*]}"
for suggestion in "${COMPREPLY[@]}"; do
echo "$suggestion"
done

3 changes: 2 additions & 1 deletion spec/completely/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ ftp:

- compline: "ftp download "
expected: [--help, --override, another-dir, dummy-dir, ftp.yaml, gradual.yaml]
expected: [--help, --override, another-dir, dir with spaces, dummy-dir, file with spaces.txt, ftp.yaml, gradual.yaml]

- compline: "ftp upload "
expected: [--confirm, --help, another-dir, dummy-dir]
expected: [--confirm, --help, another-dir, dir with spaces, dummy-dir]

- compline: "ftp connect ssh "
expected: [--keyfile]
Expand Down
4 changes: 2 additions & 2 deletions spec/completely/zsh_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

describe "completions script and test script" do
it "returns completions without erroring" do
expect(subject).to eq "somedir --help --force"
expect(subject).to eq "somedir\n--help\n--force"
end

context "on bash" do
let(:shell) { 'bash' }

it "returns the same output" do
expect(subject).to eq "somedir --help --force"
expect(subject).to eq "somedir\n--help\n--force"
end
end
end
Expand Down
Empty file.
1 change: 1 addition & 0 deletions spec/fixtures/integration/file with spaces.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<-- more spaces
8 changes: 4 additions & 4 deletions spec/fixtures/tester/default.bash
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ _cli_completions() {

case "$compline" in
'command childcommand'*)
COMPREPLY=($(compgen -W "--quiet --verbose -q -v" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--quiet --verbose -q -v" -- "$cur" )
;;

'command subcommand'*)
COMPREPLY=($(compgen -W "--force --quiet" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--force --quiet" -- "$cur" )
;;

'command'*)
COMPREPLY=($(compgen -W "subcommand childcommand" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "subcommand childcommand" -- "$cur" )
;;

*)
COMPREPLY=($(compgen -W "--help --version command conquer" -- "$cur"))
while read; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "--help --version command conquer" -- "$cur" )
;;

esac
Expand Down