mirror of
https://github.com/pi-hole/pi-hole.git
synced 2024-11-26 08:03:18 +00:00
Bash completion (#5516)
This commit is contained in:
commit
ac86ae1e4c
3 changed files with 15 additions and 35 deletions
|
@ -24,7 +24,7 @@ fi
|
||||||
getLocalVersion() {
|
getLocalVersion() {
|
||||||
case ${1} in
|
case ${1} in
|
||||||
"Pi-hole" ) echo "${CORE_VERSION:=N/A}";;
|
"Pi-hole" ) echo "${CORE_VERSION:=N/A}";;
|
||||||
"web" ) echo "${WEB_VERSION:=N/A}";;
|
"web" ) echo "${WEB_VERSION:=N/A}";;
|
||||||
"FTL" ) echo "${FTL_VERSION:=N/A}";;
|
"FTL" ) echo "${FTL_VERSION:=N/A}";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ getLocalVersion() {
|
||||||
getLocalHash() {
|
getLocalHash() {
|
||||||
case ${1} in
|
case ${1} in
|
||||||
"Pi-hole" ) echo "${CORE_HASH:=N/A}";;
|
"Pi-hole" ) echo "${CORE_HASH:=N/A}";;
|
||||||
"web" ) echo "${WEB_HASH:=N/A}";;
|
"web" ) echo "${WEB_HASH:=N/A}";;
|
||||||
"FTL" ) echo "${FTL_HASH:=N/A}";;
|
"FTL" ) echo "${FTL_HASH:=N/A}";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ getLocalHash() {
|
||||||
getRemoteHash(){
|
getRemoteHash(){
|
||||||
case ${1} in
|
case ${1} in
|
||||||
"Pi-hole" ) echo "${GITHUB_CORE_HASH:=N/A}";;
|
"Pi-hole" ) echo "${GITHUB_CORE_HASH:=N/A}";;
|
||||||
"web" ) echo "${GITHUB_WEB_HASH:=N/A}";;
|
"web" ) echo "${GITHUB_WEB_HASH:=N/A}";;
|
||||||
"FTL" ) echo "${GITHUB_FTL_HASH:=N/A}";;
|
"FTL" ) echo "${GITHUB_FTL_HASH:=N/A}";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ getRemoteHash(){
|
||||||
getRemoteVersion(){
|
getRemoteVersion(){
|
||||||
case ${1} in
|
case ${1} in
|
||||||
"Pi-hole" ) echo "${GITHUB_CORE_VERSION:=N/A}";;
|
"Pi-hole" ) echo "${GITHUB_CORE_VERSION:=N/A}";;
|
||||||
"web" ) echo "${GITHUB_WEB_VERSION:=N/A}";;
|
"web" ) echo "${GITHUB_WEB_VERSION:=N/A}";;
|
||||||
"FTL" ) echo "${GITHUB_FTL_VERSION:=N/A}";;
|
"FTL" ) echo "${GITHUB_FTL_VERSION:=N/A}";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ getRemoteVersion(){
|
||||||
getLocalBranch(){
|
getLocalBranch(){
|
||||||
case ${1} in
|
case ${1} in
|
||||||
"Pi-hole" ) echo "${CORE_BRANCH:=N/A}";;
|
"Pi-hole" ) echo "${CORE_BRANCH:=N/A}";;
|
||||||
"web" ) echo "${WEB_BRANCH:=N/A}";;
|
"web" ) echo "${WEB_BRANCH:=N/A}";;
|
||||||
"FTL" ) echo "${FTL_BRANCH:=N/A}";;
|
"FTL" ) echo "${FTL_BRANCH:=N/A}";;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
@ -114,11 +114,11 @@ defaultOutput() {
|
||||||
helpFunc() {
|
helpFunc() {
|
||||||
echo "Usage: pihole -v [repo | option] [option]
|
echo "Usage: pihole -v [repo | option] [option]
|
||||||
Example: 'pihole -v -p -l'
|
Example: 'pihole -v -p -l'
|
||||||
Show Pi-hole, Admin Console & FTL versions
|
Show Pi-hole, Web Console & FTL versions
|
||||||
|
|
||||||
Repositories:
|
Repositories:
|
||||||
-p, --pihole Only retrieve info regarding Pi-hole repository
|
-p, --pihole Only retrieve info regarding Pi-hole repository
|
||||||
-a, --admin Only retrieve info regarding web repository
|
-w, --web Only retrieve info regarding web repository
|
||||||
-f, --ftl Only retrieve info regarding FTL repository
|
-f, --ftl Only retrieve info regarding FTL repository
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
@ -131,7 +131,7 @@ Options:
|
||||||
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
"-p" | "--pihole" ) shift; versionOutput "Pi-hole" "$@";;
|
"-p" | "--pihole" ) shift; versionOutput "Pi-hole" "$@";;
|
||||||
"-a" | "--admin" ) shift; versionOutput "web" "$@";;
|
"-w" | "--web" ) shift; versionOutput "web" "$@";;
|
||||||
"-f" | "--ftl" ) shift; versionOutput "FTL" "$@";;
|
"-f" | "--ftl" ) shift; versionOutput "FTL" "$@";;
|
||||||
"-h" | "--help" ) helpFunc;;
|
"-h" | "--help" ) helpFunc;;
|
||||||
* ) defaultOutput "$@";;
|
* ) defaultOutput "$@";;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
_pihole() {
|
_pihole() {
|
||||||
local cur prev opts opts_admin opts_checkout opts_debug opts_interface opts_logging opts_privacy opts_query opts_update opts_version
|
local cur prev opts opts_checkout opts_debug opts_logging opts_query opts_update opts_version
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
@ -7,17 +7,13 @@ _pihole() {
|
||||||
|
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
"pihole")
|
"pihole")
|
||||||
opts="admin blacklist checkout debug disable enable flush help logging query reconfigure regex restartdns status tail uninstall updateGravity updatePihole version wildcard whitelist arpflush"
|
opts="blacklist checkout debug disable enable flush help logging query reconfigure regex restartdns status tail uninstall updateGravity updatePihole version wildcard whitelist arpflush"
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
"whitelist"|"blacklist"|"wildcard"|"regex")
|
"whitelist"|"blacklist"|"wildcard"|"regex")
|
||||||
opts_lists="\--delmode \--noreload \--quiet \--list \--nuke"
|
opts_lists="\--delmode \--noreload \--quiet \--list \--nuke"
|
||||||
COMPREPLY=( $(compgen -W "${opts_lists}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts_lists}" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
"admin")
|
|
||||||
opts_admin="celsius fahrenheit interface kelvin password privacylevel"
|
|
||||||
COMPREPLY=( $(compgen -W "${opts_admin}" -- ${cur}) )
|
|
||||||
;;
|
|
||||||
"checkout")
|
"checkout")
|
||||||
opts_checkout="core ftl web master dev"
|
opts_checkout="core ftl web master dev"
|
||||||
COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts_checkout}" -- ${cur}) )
|
||||||
|
@ -31,7 +27,7 @@ _pihole() {
|
||||||
COMPREPLY=( $(compgen -W "${opts_logging}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts_logging}" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
"query")
|
"query")
|
||||||
opts_query="-adlist -all -exact"
|
opts_query="--partial --all"
|
||||||
COMPREPLY=( $(compgen -W "${opts_query}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts_query}" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
"updatePihole"|"-up")
|
"updatePihole"|"-up")
|
||||||
|
@ -39,25 +35,9 @@ _pihole() {
|
||||||
COMPREPLY=( $(compgen -W "${opts_update}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts_update}" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
"version")
|
"version")
|
||||||
opts_version="\--admin \--current \--ftl \--hash \--latest \--pihole"
|
opts_version="\--web \--current \--ftl \--hash \--latest \--pihole"
|
||||||
COMPREPLY=( $(compgen -W "${opts_version}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts_version}" -- ${cur}) )
|
||||||
;;
|
;;
|
||||||
"interface")
|
|
||||||
if ( [[ "$prev2" == "admin" ]] || [[ "$prev2" == "-a" ]] ); then
|
|
||||||
opts_interface="$(cat /proc/net/dev | cut -d: -s -f1)"
|
|
||||||
COMPREPLY=( $(compgen -W "${opts_interface}" -- ${cur}) )
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"privacylevel")
|
|
||||||
if ( [[ "$prev2" == "admin" ]] || [[ "$prev2" == "-a" ]] ); then
|
|
||||||
opts_privacy="0 1 2 3"
|
|
||||||
COMPREPLY=( $(compgen -W "${opts_privacy}" -- ${cur}) )
|
|
||||||
else
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
"core"|"admin"|"ftl")
|
"core"|"admin"|"ftl")
|
||||||
if [[ "$prev2" == "checkout" ]]; then
|
if [[ "$prev2" == "checkout" ]]; then
|
||||||
opts_checkout="master dev"
|
opts_checkout="master dev"
|
||||||
|
|
|
@ -332,7 +332,7 @@ package_manager_detect() {
|
||||||
# Packages required to run this install script
|
# Packages required to run this install script
|
||||||
INSTALLER_DEPS=(git iproute2 dialog ca-certificates)
|
INSTALLER_DEPS=(git iproute2 dialog ca-certificates)
|
||||||
# Packages required to run Pi-hole
|
# Packages required to run Pi-hole
|
||||||
PIHOLE_DEPS=(cron curl iputils-ping psmisc sudo unzip libcap2-bin dns-root-data libcap2 netcat-openbsd procps jq lshw)
|
PIHOLE_DEPS=(cron curl iputils-ping psmisc sudo unzip libcap2-bin dns-root-data libcap2 netcat-openbsd procps jq lshw bash-completion)
|
||||||
|
|
||||||
# If apt-get is not found, check for rpm.
|
# If apt-get is not found, check for rpm.
|
||||||
elif is_command rpm ; then
|
elif is_command rpm ; then
|
||||||
|
@ -349,7 +349,7 @@ package_manager_detect() {
|
||||||
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
PKG_COUNT="${PKG_MANAGER} check-update | grep -E '(.i686|.x86|.noarch|.arm|.src|.riscv64)' | wc -l || true"
|
||||||
OS_CHECK_DEPS=(grep bind-utils)
|
OS_CHECK_DEPS=(grep bind-utils)
|
||||||
INSTALLER_DEPS=(git dialog iproute newt procps-ng chkconfig ca-certificates binutils)
|
INSTALLER_DEPS=(git dialog iproute newt procps-ng chkconfig ca-certificates binutils)
|
||||||
PIHOLE_DEPS=(cronie curl findutils sudo unzip psmisc libcap nmap-ncat jq lshw)
|
PIHOLE_DEPS=(cronie curl findutils sudo unzip psmisc libcap nmap-ncat jq lshw bash-completion)
|
||||||
|
|
||||||
# If neither apt-get or yum/dnf package managers were found
|
# If neither apt-get or yum/dnf package managers were found
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue