1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-07-01 21:02:34 +00:00

Define "silent" as default option and include "verbose" to the man page

Signed-off-by: RD WebDesign <github@rdwebdesign.com.br>
This commit is contained in:
RD WebDesign 2025-05-11 19:51:27 -03:00
parent 190798e572
commit dee44cb3da
No known key found for this signature in database
GPG Key ID: AE3C7FC910687F33
3 changed files with 23 additions and 13 deletions

View File

@ -301,19 +301,19 @@ secretRead() {
}
apiFunc() {
local data response status status_col verbose
local data response status status_col verbosity
# Define if the output will be verbose (default) or silent
verbose="verbose"
if [ "$1" = "silent" ] || [ "$1" = "-s" ]; then
verbose=""
# Define if the output will be silent (default) or verbose
verbosity="silent"
if [ "$1" = "verbose" ]; then
verbosity="verbose"
shift
fi
# Authenticate with the API
LoginAPI "${verbose}"
LoginAPI "${verbosity}"
if [ "${verbose}" = "verbose" ]; then
if [ "${verbosity}" = "verbose" ]; then
echo ""
echo "Requesting: ${COL_PURPLE}GET ${COL_CYAN}${API_URL}${COL_YELLOW}$1${COL_NC}"
echo ""
@ -336,13 +336,13 @@ apiFunc() {
fi
# Only print the status in verbose mode or if the status is not 200
if [ "${verbose}" = "verbose" ] || [ "${status}" != 200 ]; then
if [ "${verbosity}" = "verbose" ] || [ "${status}" != 200 ]; then
echo "Status: ${status_col}${status}${COL_NC}"
fi
# Output the data. Format it with jq if available and data is actually JSON.
# Otherwise just print it
if [ "${verbose}" = "verbose" ]; then
if [ "${verbosity}" = "verbose" ]; then
echo "Data:"
fi
@ -353,5 +353,5 @@ apiFunc() {
fi
# Delete the session
LogoutAPI "${verbose}"
LogoutAPI "${verbosity}"
}

View File

@ -23,7 +23,7 @@ pihole -r
.br
\fBpihole -g\fR
.br
\fBpihole\fR -\fBq\fR [options]
\fBpihole\fR \fB-q\fR [options]
.br
\fBpihole\fR \fB-l\fR (\fBon|off|off noflush\fR)
.br
@ -43,7 +43,7 @@ pihole -r
.br
\fBpihole\fR \fBcheckout\fR repo [branch]
.br
\fBpihole\fR \api\fR endpoint
\fBpihole\fR \fBapi\fR [verbose] endpoint
.br
\fBpihole\fR \fBhelp\fR
.br
@ -234,10 +234,14 @@ Available commands and options:
branchname Update subsystems to the specified branchname
.br
\fBapi\fR endpoint
\fBapi\fR [verbose] endpoint
.br
Query the Pi-hole API at <endpoint>
.br
verbose Show authentication and status messages
.br
.SH "EXAMPLE"
Some usage examples
@ -323,6 +327,11 @@ Switching Pi-hole subsystem branches
Queries FTL for the stats/summary endpoint
.br
\fBpihole api verbose stats/summary\fR
.br
Same as above, but shows authentication and status messages
.br
.SH "COLOPHON"
Get sucked into the latest news and community activity by entering Pi-hole's orbit. Information about Pi-hole, and the latest version of the software can be found at https://pi-hole.net.

1
pihole
View File

@ -493,6 +493,7 @@ Debugging Options:
Add an optional argument to filter the log
(regular expressions are supported)
api <endpoint> Query the Pi-hole API at <endpoint>
Precede <endpoint> with 'verbose' option to show authentication and status messages
Options: