mirror of
https://gitea.invidious.io/iv-org/youtube-utils.git
synced 2024-08-15 00:53:16 +00:00
Add --debug option & don't display request by default
This commit is contained in:
parent
3244003608
commit
d24f7a9c59
1 changed files with 16 additions and 4 deletions
|
@ -17,6 +17,8 @@ print_help()
|
|||
echo " -i,--interactive Run in interactive mode"
|
||||
echo " -o,--output Print output to file instead of stdout"
|
||||
echo ""
|
||||
echo " --debug Show what is sent to the API"
|
||||
echo ""
|
||||
}
|
||||
|
||||
print_clients()
|
||||
|
@ -47,7 +49,7 @@ query_with_default()
|
|||
prompt="$1"
|
||||
default="$2"
|
||||
|
||||
printf "\n%s [%s]: " "$prompt" "$default" >&2
|
||||
printf "%s [%s]: " "$prompt" "$default" >&2
|
||||
read -r data
|
||||
|
||||
if [ -z "$data" ]; then
|
||||
|
@ -62,7 +64,7 @@ query_with_error()
|
|||
prompt="$1"
|
||||
error_message="$2"
|
||||
|
||||
printf "\n%s []: " "$prompt" >&2
|
||||
printf "%s []: " "$prompt" >&2
|
||||
read -r data
|
||||
|
||||
if [ -z "$data" ]; then
|
||||
|
@ -83,6 +85,7 @@ is_arg()
|
|||
-h|--help) true;;
|
||||
-i|--interactive) true;;
|
||||
-o|--output) true;;
|
||||
--debug) true;;
|
||||
*) false;;
|
||||
esac
|
||||
}
|
||||
|
@ -93,6 +96,7 @@ is_arg()
|
|||
#
|
||||
|
||||
interactive=false
|
||||
debug=false
|
||||
|
||||
client_option=""
|
||||
endpoint_option=""
|
||||
|
@ -162,6 +166,10 @@ while :; do
|
|||
output="$1"
|
||||
;;
|
||||
|
||||
--debug)
|
||||
debug=true
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Error: unknown argument '$1'"
|
||||
exit 2
|
||||
|
@ -392,8 +400,12 @@ if [ $interactive = true ]; then
|
|||
data="{\"context\":{\"client\":{$client}},$partial_data}"
|
||||
|
||||
# Basic debug
|
||||
echo "sending:"
|
||||
echo "$data" | sed 's/{/{\n/g; s/}/\n}/g; s/,/,\n/g'
|
||||
if [ $debug = true ]; then
|
||||
echo
|
||||
echo "sending:"
|
||||
echo "$data" | sed 's/{/{\n/g; s/}/\n}/g; s/,/,\n/g'
|
||||
echo
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue