From ccdbfd41309346ebb955e8910f2c130b92cd60d8 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 25 Jun 2024 13:56:49 +0200 Subject: [PATCH] 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 --- advanced/Scripts/list.sh | 9 ++++--- advanced/bash-completion/pihole | 6 ++--- manpages/pihole.8 | 42 +++++++++++++++------------------ pihole | 25 ++++++++++---------- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/advanced/Scripts/list.sh b/advanced/Scripts/list.sh index 3bd4af75..144317ce 100755 --- a/advanced/Scripts/list.sh +++ b/advanced/Scripts/list.sh @@ -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;; diff --git a/advanced/bash-completion/pihole b/advanced/bash-completion/pihole index 89e02d2f..064193b4 100644 --- a/advanced/bash-completion/pihole +++ b/advanced/bash-completion/pihole @@ -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") diff --git a/manpages/pihole.8 b/manpages/pihole.8 index 55bbe6cb..1bf917db 100644 --- a/manpages/pihole.8 +++ b/manpages/pihole.8 @@ -52,47 +52,43 @@ pihole restartdns\fR [options] Available commands and options: .br -\fB-w, whitelist\fR [options] [ ] +\fBallow, allowlist\fR [options] [ ] .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] [ ] +\fBdeny, denylist\fR [options] [ ] .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] [ ] .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] [ ] +\fB--allow-regex\fR [options] [ ] .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] [ ] .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] [ ] +\fB--allow-wild\fR [options] [ ] .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 + not, -d, --delmode Remove domain(s) from the list .br - -nr, --noreload Update list without refreshing dnsmasq + -q, --quiet Make output less verbose .br - -q, --quiet Make output less verbose -.br - -l, --list Display all your listed domains -.br - --nuke Removes all entries in a list + -l, --list Display all your listed domains .br \fB-d, debug\fR [-a] @@ -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 diff --git a/pihole b/pihole index 1313d487..5a3c847d 100755 --- a/pihole +++ b/pihole @@ -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