Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
liblinphone
Commits
5aeb75c9
Commit
5aeb75c9
authored
10 years ago
by
Gautier Pelloux-Prayer
Browse files
Options
Download
Patches
Plain Diff
Update completions script to handle properly commads with arg
parent
1d753498
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tester/liblinphone_completion
+22
-19
tester/liblinphone_completion
with
22 additions
and
19 deletions
tester/liblinphone_completion
+
22
−
19
View file @
5aeb75c9
...
...
@@ -21,10 +21,7 @@
# source this file in your .rc file
_liblinphone_complete() {
local completions command_require_argument prev_arg latest_arg available_tasks has_not_set_suite suite_name
# these commands expect an argument
command_require_argument=(--list-tests --config --domain --auth-domain --dns-hosts --suite --test)
local completions command_requiring_argument prev_arg latest_arg available_tasks has_not_set_suite suite_name
if [ -n "$BASH_VERSION" ]; then
set -- "${COMP_WORDS[@]}" #convert them to arguments (eg $1,$#,$@,etc.)
...
...
@@ -37,7 +34,6 @@ _liblinphone_complete() {
program=$1
shift
# if user required help, do not complete anything
if ! grep -q -- "--help" <<< "$@"; then
# retrieve the last argument
...
...
@@ -55,6 +51,10 @@ _liblinphone_complete() {
# get the tasks available, from --help
available_tasks="$($program 2>&1 --help | sed -nE "s/.*--([^ ]*).*/--\\1/p")"
# these commands expect an argument
command_requiring_argument="$($program 2>&1 --help | sed -nE "s/.*--(.*) <.*/--\\1/p")"
# remove all already provided tasks (it's useless to provide them twice)
if [[ ! -z "$@" ]]; then
current_tasks=$(echo $@ | grep -Eo -- "--([^ ])*" | tr '\n' '|' | sed 's/|/$|/g')--$
...
...
@@ -85,26 +85,29 @@ _liblinphone_complete() {
elif [ "$latest_arg" = "--suite" ] || [ "$latest_arg" = "--list-tests" ]; then
completions="$($program --list-suites)"
# we are waiting for a custom value, so do not hint anything
elif grep -q -- "
$latest_arg
" <<< "$command_requir
e
_argument"; then
elif grep -q -- "
^
$latest_arg
$
" <<< "$command_requir
ing
_argument"; then
completions=""
else
completions="$available_tasks"
fi
fi
if [ -n "$BASH_VERSION" ]; then
# COMPREPLY=( $(echo $completions | sed 's/ /\\ /g' )) #| sed -e 's/^/"/g' -e 's/$/"/g' | tr '\n' ' ') )
IFS=$'\n'
COMPREPLY=($(compgen -W "${completions}" -- ${COMP_WORDS[COMP_CWORD]}))
elif [ -n "$ZSH_VERSION" ]; then
reply=( "${(ps:\n:)completions}" )
if [ ! -z "$completions" ]; then
if [ -n "$BASH_VERSION" ]; then
IFS=$'\n' #if that even necessary?
COMPREPLY=($(compgen -W "${completions}" -- ${COMP_WORDS[COMP_CWORD]}))
elif [ -n "$ZSH_VERSION" ]; then
reply=( "${(ps:\n:)completions}" )
fi
fi
}
if [ -n "$BASH_VERSION" ]; then
complete -F _liblinphone_complete liblinphone_tester
elif [ -n "$ZSH_VERSION" ]; then
compctl -K _liblinphone_complete liblinphone_tester
else
echo "Your shell might be not supported! Only bash and zsh tested."
fi
for tester in liblinphone_tester mediastreamer2_tester belle_sip_tester; do
if [ -n "$BASH_VERSION" ]; then
complete -F _liblinphone_complete $tester
elif [ -n "$ZSH_VERSION" ]; then
compctl -K _liblinphone_complete $tester
else
echo "Your shell might be not supported! Only bash and zsh tested."
fi
done
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets