Comparison

mod_rest/example/rest.sh @ 6329:c95dffd984a4

mod_rest: Add -v flag to example script to allow increasing verbosity
author Kim Alvefur <zash@zash.se>
date Thu, 03 Jul 2025 17:50:18 +0200
parent 6328:887ed0f6e275
comparison
equal deleted inserted replaced
6328:887ed0f6e275 6329:c95dffd984a4
16 } 16 }
17 17
18 # Settings 18 # Settings
19 HOST="" 19 HOST=""
20 DOMAIN="" 20 DOMAIN=""
21 PRINT="b"
21 22
22 SESSION="session-read-only" 23 SESSION="session-read-only"
23 24
24 if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then 25 if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then
25 # Config file can contain the above settings 26 # Config file can contain the above settings
33 if [[ $# == 0 ]]; then 34 if [[ $# == 0 ]]; then
34 usage 35 usage
35 exit 1 36 exit 1
36 fi 37 fi
37 38
38 while getopts 'r:h:' flag; do 39 while getopts 'vr:h:' flag; do
39 case "$flag" in 40 case "$flag" in
41 v)
42 case "$PRINT" in
43 b)
44 PRINT="Bb"
45 ;;
46 Bb)
47 PRINT="HBhb"
48 ;;
49 HBhb)
50 PRINT="HBhbm"
51 ;;
52 esac
53 ;;
40 r) 54 r)
41 case "$OPTARG" in 55 case "$OPTARG" in
42 o) 56 o)
43 # Default 57 # Default
44 SESSION="session-read-only" 58 SESSION="session-read-only"
86 if [[ "$1" == /* ]]; then 100 if [[ "$1" == /* ]]; then
87 GET_PATH="$1" 101 GET_PATH="$1"
88 shift 1 102 shift 1
89 fi 103 fi
90 104
91 https --check-status -p b --"$SESSION" rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@" 105 https --check-status -p "$PRINT" --"$SESSION" rest -A oauth2 -a "$HOST" --oauth2-scope "$SCOPE" "$HOST/rest$GET_PATH" "$@"