Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[some help required] Add bash completions #542

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 16 additions & 0 deletions share/bash-completion/completions/msguntypot
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# bash completion for po4a(7) utilities. -*- shell-script -*-
# this file provides completion for msguntypot

_comp_cmd_po4a_msguntypot() {
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-o -n' -- "$cur" ) )
return
fi

_filedir
} && complete -F _comp_cmd_po4a_msguntypot msguntypot

# ex: filetype=sh
50 changes: 50 additions & 0 deletions share/bash-completion/completions/po4a
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# bash completion for po4a(7) utilities. -*- shell-script -*-
# this file provides completions for po4a itself and old-style scripts:
# po4a-updatepo po4a-normalize po4a-gettextize po4a-translate

_comp_cmd_po4a_utils() {
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

local cmd="$(basename "${comp_args[0]}")"

case $prev in
-h | --help | -V | --version) return ;;
--help-format) [[ "$cmd" != "po4a" ]] && return ;;
--porefs)
if [[ "$cmd" != "po4a-translate" ]]; then
COMPREPLY=( $( compgen -W 'never file counter full' -- "$cur" ) )
return
fi
;;
-f | --format)
if [[ "$cmd" != "po4a" ]]; then
local formats="
$(command "${cmd}" --help-format 2>&1 | {
local rx='^ - ([a-z]+):';
while IFS= read line; do
[[ $line =~ $rx ]] && echo "${BASH_REMATCH[1]}"
done
})"

COMPREPLY=( $( compgen -W "${formats}" -- "$cur" ) )
return
fi
;;
esac

if [[ $cur == -* ]]; then
# po4a lists some arguments of other commands in its help message and
# they can end up first on the line e.g. msgmerge's "-U", so we should
# avoid leeking them to complitiones
_comp_compgen_help - < <(
command "${comp_args[0]}" --help 2>/dev/null |
command grep '^ -' 2>/dev/null
)
return
fi

_filedir
} && complete -F _comp_cmd_po4a_utils po4a po4a-updatepo po4a-normalize po4a-gettextize po4a-translate

# ex: filetype=sh
1 change: 1 addition & 0 deletions share/bash-completion/completions/po4a-display-man
16 changes: 16 additions & 0 deletions share/bash-completion/completions/po4a-display-pod
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# bash completion for po4a(7) utilities. -*- shell-script -*-
# this file provides completion for po4a-display-pod and po4a-display-man

_comp_cmd_po4a_scripts() {
local cur prev words cword comp_args
_comp_initialize -- "$@" || return

if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '-m -o -p' -- "$cur" ) )
return
fi

_filedir
} && complete -F _comp_cmd_po4a_scripts po4a-display-pod po4a-display-man

# ex: filetype=sh
1 change: 1 addition & 0 deletions share/bash-completion/completions/po4a-gettextize
1 change: 1 addition & 0 deletions share/bash-completion/completions/po4a-normalize
1 change: 1 addition & 0 deletions share/bash-completion/completions/po4a-translate
1 change: 1 addition & 0 deletions share/bash-completion/completions/po4a-updatepo
Loading