Skip to content

Commit 8172be2

Browse files
committed
- Improve template
1 parent a9609c7 commit 8172be2

File tree

9 files changed

+63
-35
lines changed

9 files changed

+63
-35
lines changed

lib/completely/completions.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ def load(config_path, function_name: nil)
1010
begin
1111
data = YAML.load_file config_path, aliases: true
1212
rescue ArgumentError
13+
# :nocov:
1314
data = YAML.load_file config_path
15+
# :nocov:
1416
end
1517

1618
new data, function_name: function_name

lib/completely/template.erb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
# Bash completion script -*- shell-script -*-
1+
# <%= "#{command} completion".ljust 56 %> -*- shell-script -*-
22

33
# This bash completions script was generated by
44
# completely (https://github.com/dannyben/completely)
55
# Modifying it manually is not recommended
66

77
<%= function_name %>() {
8+
local cur comp_line
89
_init_completion -s || return
9-
10-
local cur=${COMP_WORDS[COMP_CWORD]}
11-
local comp_line="${COMP_WORDS[@]:1}"
10+
cur=${COMP_WORDS[COMP_CWORD]}
11+
comp_line="${COMP_WORDS[@]:1}"
1212

1313
case "$comp_line" in
1414
% patterns.each do |pattern|
1515
% next if pattern.empty?
1616
'<%= pattern.text_without_prefix %>'*) COMPREPLY=($(compgen <%= pattern.compgen %> -- "$cur")) ;;
1717
% end
1818
esac
19-
} && complete -F <%= function_name %> -o bashdefault -o default <%= command %>
19+
} &&
20+
complete -F <%= function_name %> -o bashdefault -o default <%= command %>
2021

2122
# ex: filetype=sh
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
#!/usr/bin/env bash
1+
# mygit completion -*- shell-script -*-
22

33
# This bash completions script was generated by
44
# completely (https://github.com/dannyben/completely)
55
# Modifying it manually is not recommended
6+
67
_mygit_completions() {
7-
local cur=${COMP_WORDS[COMP_CWORD]}
8-
local comp_line="${COMP_WORDS[@]:1}"
8+
local cur comp_line
9+
_init_completion -s || return
10+
cur=${COMP_WORDS[COMP_CWORD]}
11+
comp_line="${COMP_WORDS[@]:1}"
912

1013
case "$comp_line" in
1114
'status'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;
1215
'commit'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;
1316
'init'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;
1417
''*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;
1518
esac
16-
}
19+
} &&
20+
complete -F _mygit_completions -o bashdefault -o default mygit
1721

18-
complete -F _mygit_completions mygit
22+
# ex: filetype=sh
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1-
#!/usr/bin/env bash
1+
# mygit completion -*- shell-script -*-
22

33
# This bash completions script was generated by
44
# completely (https://github.com/dannyben/completely)
55
# Modifying it manually is not recommended
6+
67
_mycomps() {
7-
local cur=${COMP_WORDS[COMP_CWORD]}
8-
local comp_line="${COMP_WORDS[@]:1}"
8+
local cur comp_line
9+
_init_completion -s || return
10+
cur=${COMP_WORDS[COMP_CWORD]}
11+
comp_line="${COMP_WORDS[@]:1}"
912

1013
case "$comp_line" in
1114
'status'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;
1215
'commit'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;
1316
'init'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;
1417
''*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;
1518
esac
16-
}
19+
} &&
20+
complete -F _mycomps -o bashdefault -o default mygit
1721

18-
complete -F _mycomps mygit
22+
# ex: filetype=sh
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
give_comps() {
2-
echo $'#!/usr/bin/env bash'
2+
echo $'# mygit completion -*- shell-script -*-'
33
echo $''
44
echo $'# This bash completions script was generated by'
55
echo $'# completely (https://github.com/dannyben/completely)'
66
echo $'# Modifying it manually is not recommended'
7+
echo $''
78
echo $'_mygit_completions() {'
8-
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
9-
echo $' local comp_line="${COMP_WORDS[@]:1}"'
9+
echo $' local cur comp_line'
10+
echo $' _init_completion -s || return'
11+
echo $' cur=${COMP_WORDS[COMP_CWORD]}'
12+
echo $' comp_line="${COMP_WORDS[@]:1}"'
1013
echo $''
1114
echo $' case "$comp_line" in'
1215
echo $' \'status\'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;'
1316
echo $' \'commit\'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;'
1417
echo $' \'init\'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;'
1518
echo $' \'\'*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;'
1619
echo $' esac'
17-
echo $'}'
20+
echo $'} &&'
21+
echo $'complete -F _mygit_completions -o bashdefault -o default mygit'
1822
echo $''
19-
echo $'complete -F _mygit_completions mygit'
23+
echo $'# ex: filetype=sh'
2024
}
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
send_completions() {
2-
echo $'#!/usr/bin/env bash'
2+
echo $'# completely completion -*- shell-script -*-'
33
echo $''
44
echo $'# This bash completions script was generated by'
55
echo $'# completely (https://github.com/dannyben/completely)'
66
echo $'# Modifying it manually is not recommended'
7+
echo $''
78
echo $'_completely_completions() {'
8-
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
9-
echo $' local comp_line="${COMP_WORDS[@]:1}"'
9+
echo $' local cur comp_line'
10+
echo $' _init_completion -s || return'
11+
echo $' cur=${COMP_WORDS[COMP_CWORD]}'
12+
echo $' comp_line="${COMP_WORDS[@]:1}"'
1013
echo $''
1114
echo $' case "$comp_line" in'
1215
echo $' \'generate\'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;'
1316
echo $' \'init\'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;'
1417
echo $' \'\'*) COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur")) ;;'
1518
echo $' esac'
16-
echo $'}'
19+
echo $'} &&'
20+
echo $'complete -F _completely_completions -o bashdefault -o default completely'
1721
echo $''
18-
echo $'complete -F _completely_completions completely'
22+
echo $'# ex: filetype=sh'
1923
}

spec/approvals/completions/script

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
#!/usr/bin/env bash
1+
# completely completion -*- shell-script -*-
22

33
# This bash completions script was generated by
44
# completely (https://github.com/dannyben/completely)
55
# Modifying it manually is not recommended
6+
67
_completely_completions() {
7-
local cur=${COMP_WORDS[COMP_CWORD]}
8-
local comp_line="${COMP_WORDS[@]:1}"
8+
local cur comp_line
9+
_init_completion -s || return
10+
cur=${COMP_WORDS[COMP_CWORD]}
11+
comp_line="${COMP_WORDS[@]:1}"
912

1013
case "$comp_line" in
1114
'generate'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;
1215
'init'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;
1316
''*) COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur")) ;;
1417
esac
15-
}
18+
} &&
19+
complete -F _completely_completions -o bashdefault -o default completely
1620

17-
complete -F _completely_completions completely
21+
# ex: filetype=sh
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1-
#!/usr/bin/env bash
1+
# completely completion -*- shell-script -*-
22

33
# This bash completions script was generated by
44
# completely (https://github.com/dannyben/completely)
55
# Modifying it manually is not recommended
6+
67
_completely_completions() {
7-
local cur=${COMP_WORDS[COMP_CWORD]}
8-
local comp_line="${COMP_WORDS[@]:1}"
8+
local cur comp_line
9+
_init_completion -s || return
10+
cur=${COMP_WORDS[COMP_CWORD]}
11+
comp_line="${COMP_WORDS[@]:1}"
912

1013
case "$comp_line" in
1114
'generate'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;
1215
'init'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;
1316
esac
14-
}
17+
} &&
18+
complete -F _completely_completions -o bashdefault -o default completely
1519

16-
complete -F _completely_completions completely
20+
# ex: filetype=sh

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def run_completions(fixture:, compline:, cword:)
2525
File.write "spec/tmp/test.sh", <<~BASH
2626
#{subject.script}
2727
28+
source /usr/share/bash-completion/bash_completion
2829
COMP_WORDS=( #{compline} )
2930
COMP_CWORD=#{cword}
3031
_testme

0 commit comments

Comments
 (0)