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: 2 additions & 0 deletions lib/completely/completions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def load(config_path, function_name: nil)
begin
data = YAML.load_file config_path, aliases: true
rescue ArgumentError
# :nocov:
data = YAML.load_file config_path
# :nocov:
end

new data, function_name: function_name
Expand Down
14 changes: 9 additions & 5 deletions lib/completely/template.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/usr/bin/env bash
# <%= "#{command} completion".ljust 56 %> -*- shell-script -*-

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

<%= function_name %>() {
local cur=${COMP_WORDS[COMP_CWORD]}
local comp_line="${COMP_WORDS[@]:1}"
local cur comp_line
_init_completion -s || return
cur=${COMP_WORDS[COMP_CWORD]}
comp_line="${COMP_WORDS[@]:1}"

case "$comp_line" in
% patterns.each do |pattern|
% next if pattern.empty?
'<%= pattern.text_without_prefix %>'*) COMPREPLY=($(compgen <%= pattern.compgen %> -- "$cur")) ;;
% end
esac
}

} &&
complete -F <%= function_name %> <%= command %>

# ex: filetype=sh
14 changes: 9 additions & 5 deletions spec/approvals/cli/generated-script
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/usr/bin/env bash
# mygit completion -*- shell-script -*-

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

_mygit_completions() {
local cur=${COMP_WORDS[COMP_CWORD]}
local comp_line="${COMP_WORDS[@]:1}"
local cur comp_line
_init_completion -s || return
cur=${COMP_WORDS[COMP_CWORD]}
comp_line="${COMP_WORDS[@]:1}"

case "$comp_line" in
'status'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;
'commit'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;
'init'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;
''*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;
esac
}

} &&
complete -F _mygit_completions mygit

# ex: filetype=sh
14 changes: 9 additions & 5 deletions spec/approvals/cli/generated-script-alt
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#!/usr/bin/env bash
# mygit completion -*- shell-script -*-

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

_mycomps() {
local cur=${COMP_WORDS[COMP_CWORD]}
local comp_line="${COMP_WORDS[@]:1}"
local cur comp_line
_init_completion -s || return
cur=${COMP_WORDS[COMP_CWORD]}
comp_line="${COMP_WORDS[@]:1}"

case "$comp_line" in
'status'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;
'commit'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;
'init'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;
''*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;
esac
}

} &&
complete -F _mycomps mygit

# ex: filetype=sh
14 changes: 9 additions & 5 deletions spec/approvals/cli/generated-wrapped-script
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
give_comps() {
echo $'#!/usr/bin/env bash'
echo $'# mygit completion -*- shell-script -*-'
echo $''
echo $'# This bash completions script was generated by'
echo $'# completely (https://github.com/dannyben/completely)'
echo $'# Modifying it manually is not recommended'
echo $''
echo $'_mygit_completions() {'
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
echo $' local comp_line="${COMP_WORDS[@]:1}"'
echo $' local cur comp_line'
echo $' _init_completion -s || return'
echo $' cur=${COMP_WORDS[COMP_CWORD]}'
echo $' comp_line="${COMP_WORDS[@]:1}"'
echo $''
echo $' case "$comp_line" in'
echo $' \'status\'*) COMPREPLY=($(compgen -W "--help --verbose --branch $(git branch 2> /dev/null)" -- "$cur")) ;;'
echo $' \'commit\'*) COMPREPLY=($(compgen -A file -W "--help --message --all -a --quiet -q" -- "$cur")) ;;'
echo $' \'init\'*) COMPREPLY=($(compgen -A directory -W "--bare" -- "$cur")) ;;'
echo $' \'\'*) COMPREPLY=($(compgen -W "--help --version status init commit" -- "$cur")) ;;'
echo $' esac'
echo $'}'
echo $''
echo $'} &&'
echo $'complete -F _mygit_completions mygit'
echo $''
echo $'# ex: filetype=sh'
}
14 changes: 9 additions & 5 deletions spec/approvals/completions/function
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
send_completions() {
echo $'#!/usr/bin/env bash'
echo $'# completely completion -*- shell-script -*-'
echo $''
echo $'# This bash completions script was generated by'
echo $'# completely (https://github.com/dannyben/completely)'
echo $'# Modifying it manually is not recommended'
echo $''
echo $'_completely_completions() {'
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
echo $' local comp_line="${COMP_WORDS[@]:1}"'
echo $' local cur comp_line'
echo $' _init_completion -s || return'
echo $' cur=${COMP_WORDS[COMP_CWORD]}'
echo $' comp_line="${COMP_WORDS[@]:1}"'
echo $''
echo $' case "$comp_line" in'
echo $' \'generate\'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;'
echo $' \'init\'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;'
echo $' \'\'*) COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur")) ;;'
echo $' esac'
echo $'}'
echo $''
echo $'} &&'
echo $'complete -F _completely_completions completely'
echo $''
echo $'# ex: filetype=sh'
}
14 changes: 9 additions & 5 deletions spec/approvals/completions/script
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#!/usr/bin/env bash
# completely completion -*- shell-script -*-

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

_completely_completions() {
local cur=${COMP_WORDS[COMP_CWORD]}
local comp_line="${COMP_WORDS[@]:1}"
local cur comp_line
_init_completion -s || return
cur=${COMP_WORDS[COMP_CWORD]}
comp_line="${COMP_WORDS[@]:1}"

case "$comp_line" in
'generate'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;
'init'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;
''*) COMPREPLY=($(compgen -W "--help --version init generate" -- "$cur")) ;;
esac
}

} &&
complete -F _completely_completions completely

# ex: filetype=sh
14 changes: 9 additions & 5 deletions spec/approvals/completions/script-only-spaces
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/usr/bin/env bash
# completely completion -*- shell-script -*-

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

_completely_completions() {
local cur=${COMP_WORDS[COMP_CWORD]}
local comp_line="${COMP_WORDS[@]:1}"
local cur comp_line
_init_completion -s || return
cur=${COMP_WORDS[COMP_CWORD]}
comp_line="${COMP_WORDS[@]:1}"

case "$comp_line" in
'generate'*) COMPREPLY=($(compgen -A directory -W "--help --force" -- "$cur")) ;;
'init'*) COMPREPLY=($(compgen -W "--help" -- "$cur")) ;;
esac
}

} &&
complete -F _completely_completions completely

# ex: filetype=sh
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def run_completions(fixture:, compline:, cword:)
File.write "spec/tmp/test.sh", <<~BASH
#{subject.script}

source /usr/share/bash-completion/bash_completion
COMP_WORDS=( #{compline} )
COMP_CWORD=#{cword}
_testme
Expand Down