Use natural langauge for list manipulations, like pihole allow example.com or pihole deny other.net. Also remove using pihole deny not bad.org

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2024-06-25 13:56:49 +02:00
parent fe8e63853c
commit ccdbfd4130
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD
4 changed files with 39 additions and 43 deletions

View file

@ -47,11 +47,10 @@ Example: 'pihole ${abbrv} site.com', or 'pihole ${abbrv} site1.com site2.com'
${typeId^} one or more ${kindId} domains
Options:
-d, --delmode Remove domain(s)
not -d, --delmode Remove domain(s)
-q, --quiet Make output less verbose
-h, --help Show this help dialog
-l, --list Display domains
--nuke Removes all entries in a list
--comment \"text\" Add a comment to the domain. If adding multiple domains the same comment will be used for all"
exit 0
@ -198,13 +197,13 @@ GetComment() {
while (( "$#" )); do
case "${1}" in
"-a" | "allowlist" ) kindId="exact"; typeId="allow"; abbrv="-a";;
"-b" | "denylist" ) kindId="exact"; typeId="deny"; abbrv="-b";;
"allow" | "allowlist" ) kindId="exact"; typeId="allow"; abbrv="allow";;
"deny" | "denylist" ) kindId="exact"; typeId="deny"; abbrv="deny";;
"--allow-regex" | "allow-regex" ) kindId="regex"; typeId="allow"; abbrv="--allow-regex";;
"--allow-wild" | "allow-wild" ) kindId="regex"; typeId="allow"; wildcard=true; abbrv="--allow-wild";;
"--regex" | "regex" ) kindId="regex"; typeId="deny"; abbrv="--regex";;
"--wild" | "wildcard" ) kindId="regex"; typeId="deny"; wildcard=true; abbrv="--wild";;
"-d" | "--delmode" ) addmode=false;;
"-d" | "not" | "--delmode" ) addmode=false;;
"-q" | "--quiet" ) verbose=false;;
"-h" | "--help" ) helpFunc;;
"-l" | "--list" ) Displaylist;;

View file

@ -7,11 +7,11 @@ _pihole() {
case "${prev}" in
"pihole")
opts="blacklist checkout debug disable enable flush help logging query reconfigure regex restartdns status tail uninstall updateGravity updatePihole version wildcard whitelist arpflush"
opts="allow allow-regex allow-wild deny checkout debug disable enable flush help logging query reconfigure regex restartdns status tail uninstall updateGravity updatePihole version wildcard arpflush"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
;;
"whitelist"|"blacklist"|"wildcard"|"regex")
opts_lists="\--delmode \--noreload \--quiet \--list \--nuke"
"allow"|"deny"|"wildcard"|"regex"|"allow-regx"|"allow-wild")
opts_lists="\not \--delmode \--quiet \--list \--help"
COMPREPLY=( $(compgen -W "${opts_lists}" -- ${cur}) )
;;
"checkout")

View file

@ -52,48 +52,44 @@ pihole restartdns\fR [options]
Available commands and options:
.br
\fB-w, whitelist\fR [options] [<domain1> <domain2 ...>]
\fBallow, allowlist\fR [options] [<domain1> <domain2 ...>]
.br
Adds or removes specified domain or domains to the Whitelist
Adds or removes specified domain or domains to the Allowlist
.br
\fB-b, blacklist\fR [options] [<domain1> <domain2 ...>]
\fBdeny, denylist\fR [options] [<domain1> <domain2 ...>]
.br
Adds or removes specified domain or domains to the blacklist
Adds or removes specified domain or domains to the denylist
.br
\fB--regex, regex\fR [options] [<regex1> <regex2 ...>]
.br
Add or removes specified regex filter to the regex blacklist
Add or removes specified regex filter to the regex denylist
.br
\fB--white-regex\fR [options] [<regex1> <regex2 ...>]
\fB--allow-regex\fR [options] [<regex1> <regex2 ...>]
.br
Add or removes specified regex filter to the regex whitelist
Add or removes specified regex filter to the regex allowlist
.br
\fB--wild, wildcard\fR [options] [<domain1> <domain2 ...>]
.br
Add or removes specified domain to the wildcard blacklist
Add or removes specified domain to the wildcard denylist
.br
\fB--white-wild\fR [options] [<domain1> <domain2 ...>]
\fB--allow-wild\fR [options] [<domain1> <domain2 ...>]
.br
Add or removes specified domain to the wildcard whitelist
Add or removes specified domain to the wildcard allowlist
.br
(Whitelist/Blacklist manipulation options):
(Allow-/denylist manipulation options):
.br
-d, --delmode Remove domain(s) from the list
.br
-nr, --noreload Update list without refreshing dnsmasq
not, -d, --delmode Remove domain(s) from the list
.br
-q, --quiet Make output less verbose
.br
-l, --list Display all your listed domains
.br
--nuke Removes all entries in a list
.br
\fB-d, debug\fR [-a]
.br
@ -279,17 +275,17 @@ Available commands and options:
Some usage examples
.br
Whitelist/blacklist manipulation
Allow-/denylist manipulation
.br
\fBpihole -w iloveads.example.com\fR
\fBpihole allow iloveads.example.com\fR
.br
Adds "iloveads.example.com" to whitelist
Allow "iloveads.example.com"
.br
\fBpihole -b -d noads.example.com\fR
\fBpihole deny not noads.example.com\fR
.br
Removes "noads.example.com" from blacklist
Removes "noads.example.com" from denylist
.br
\fBpihole --wild example.com\fR

25
pihole
View file

@ -472,17 +472,17 @@ unsupportedFunc(){
helpFunc() {
echo "Usage: pihole [options]
Example: 'pihole -a -h'
Example: 'pihole allow -h'
Add '-h' after specific commands for more information on usage
Domain Options:
-a, allowlist Allowlist domain(s)
-b, denylist Denylist domain(s)
--regex, regex Regex denylist domains(s)
--allow-regex Regex allowlist domains(s)
--wild, wildcard Wildcard denylist domain(s)
--allow-wild Wildcard allowlist domain(s)
Add '-h' for more info on allowlist/denylist usage
allow, allowlist Allow domain(s)
deny, denylist Deny domain(s)
--regex, regex Regex deny domains(s)
--allow-regex Regex allow domains(s)
--wild, wildcard Wildcard deny domain(s)
--allow-wild Wildcard allow domain(s)
Add '-h' for more info on allow/deny usage
Debugging Options:
-d, debug Start a debugging session
@ -537,8 +537,8 @@ case "${1}" in
"tricorder" ) tricorderFunc;;
# we need to add all arguments that require sudo power to not trigger the * argument
"-a" | "allowlist" ) need_root=0;;
"-b" | "blocklist" | "denylist" ) need_root=0;;
"allow" | "allowlist" ) need_root=0;;
"deny" | "denylist" ) need_root=0;;
"--wild" | "wildcard" ) need_root=0;;
"--regex" | "regex" ) need_root=0;;
"--allow-regex" | "allow-regex" ) need_root=0;;
@ -578,8 +578,8 @@ fi
# Handle redirecting to specific functions based on arguments
case "${1}" in
"-a" | "allowlist" ) listFunc "$@";;
"-b" | "blocklist" | "denylist" ) listFunc "$@";;
"allow" | "allowlist" ) listFunc "$@";;
"deny" | "denylist" ) listFunc "$@";;
"--wild" | "wildcard" ) listFunc "$@";;
"--regex" | "regex" ) listFunc "$@";;
"--allow-regex" | "allow-regex" ) listFunc "$@";;
@ -600,4 +600,5 @@ case "${1}" in
"updatechecker" ) shift; updateCheckFunc "$@";;
"arpflush" ) arpFunc "$@";;
"-t" | "tail" ) tailFunc "$2";;
* ) helpFunc;;
esac