- Migrate to Rx3 base libray 1.1.2,

- Add bash completion script.
This commit is contained in:
2026-04-21 18:49:31 +02:00
parent 276ce11f80
commit 33bf6f7507
6 changed files with 351 additions and 106 deletions

View File

@@ -0,0 +1,65 @@
#!/bin/bash
#-----------------------------------------------------------------------------------------------------------------------------------
#
# MyIP Bash Completion
#
# Copyright (C) 2025-2026 Arnaud G. GIBERT
# mailto:arnaud@rx3.net
#
# This is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; If not, see
# <https://www.gnu.org/licenses/>.
#
#-----------------------------------------------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------------------------------------------
# MyIP Completion
#-----------------------------------------------------------------------------------------------------------------------------------
_myip_completion()
{
local mode_opts="-h --help -V --version -i --internal -a --all"
local glob_opts="-T --test -v --verbose"
local cur="${COMP_WORDS[COMP_CWORD]}"
local mode_set="FALSE"
local i
COMPREPLY=()
# Scan already provided words to detect if a mode option was given
for (( i=1; i<COMP_CWORD; i++ ))
do
case "${COMP_WORDS[i]}" in
-h|--help|-V|--version|-i|--internal|-a|--all)
mode_set="TRUE"
;;
esac
done
# Build candidate list depending on whether a mode is already set
if [[ "${mode_set}" == "TRUE" ]]
then
COMPREPLY=( $(compgen -W "${glob_opts}" -- "${cur}") )
else
COMPREPLY=( $(compgen -W "${mode_opts} ${glob_opts}" -- "${cur}") )
fi
return 0
}
complete -o filenames -F _myip_completion myip