Skip to content

Commit 949886c

Browse files
author
Danny Wahl
committed
v0.3.1
add -s, sample option outputs curl command instead of executing it
1 parent ae511ca commit 949886c

File tree

9 files changed

+66
-24
lines changed

9 files changed

+66
-24
lines changed

arc/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ OPTIONS
9595
Plain is always used when when -o <path> is used, even if color
9696
is explicitly specified in the command.
9797

98+
-s
99+
This command will output the complete curl command in a readable
100+
format. It will not execute the command.
101+
98102
-X <HTTP method>
99103
This option specifies the request method to be used by
100104
the command. Available options are:

arc/arc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ setrenderer() {
114114
local renderer="$1"
115115
case $renderer in
116116
"plain")
117-
outputrenderer="; echo -e \"\n\"" ;;
117+
outputrenderer="" ;;
118118
"color")
119119
outputrenderer="| json | pygmentize -l json" ;;
120120
*)
@@ -158,7 +158,7 @@ usage() {
158158

159159
version() {
160160
logo
161-
echo >&2 " arc-cli version 0.2.3"
161+
echo >&2 " arc-cli version 0.3.1"
162162
exit
163163
}
164164

@@ -312,7 +312,7 @@ elif [ $# -eq 0 ] && [ -f ~/.inst ]; then
312312
help
313313
else
314314
while [ $# -gt 0 ] && [ "$1" != "--" ]; do
315-
while getopts ":hlvcr:X:e:p:d:o:F:" opt; do
315+
while getopts ":hlvcsr:X:e:p:d:o:F:" opt; do
316316
case $opt in
317317
h)
318318
verbosehelp ;;
@@ -322,6 +322,8 @@ else
322322
version ;;
323323
c)
324324
setconfig ;;
325+
s)
326+
sample=true ;;
325327
r)
326328
setrenderer $OPTARG ;;
327329
X)
@@ -404,7 +406,11 @@ fi
404406
# ##############################################################################
405407

406408
command="curl $curlopts -H 'Authorization: Bearer user_id=\"$userid\", token=\"$token\"' -X $httpmethod \"https://$arc_domain.instructuremedia.com/api/$path\" $formopts $outputrenderer $outputpath"
407-
eval $command
409+
if [ "$sample" = true ]; then
410+
echo "$command"
411+
else
412+
eval $command
413+
fi
408414

409415
# DELETE SESSION ###############################################################
410416
# ##############################################################################

bridge/bridge

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ setrenderer() {
111111
local renderer="$1"
112112
case $renderer in
113113
"plain")
114-
outputrenderer="; echo -e \"\n\"" ;;
114+
outputrenderer="" ;;
115115
"color")
116116
outputrenderer="| json | pygmentize -l json" ;;
117117
*)
@@ -155,7 +155,7 @@ usage() {
155155

156156
version() {
157157
logo
158-
echo >&2 "bridge-cli version 0.2.3"
158+
echo >&2 "bridge-cli version 0.3.1"
159159
exit
160160
}
161161

@@ -296,7 +296,7 @@ elif [ $# -eq 0 ] && [ -f ~/.inst ]; then
296296
help
297297
else
298298
while [ $# -gt 0 ] && [ "$1" != "--" ]; do
299-
while getopts ":hlvcr:X:t:d:o:F:" opt; do
299+
while getopts ":hlvcsr:X:t:d:o:F:" opt; do
300300
case $opt in
301301
h)
302302
verbosehelp ;;
@@ -306,6 +306,8 @@ else
306306
version ;;
307307
c)
308308
setconfig ;;
309+
s)
310+
sample=true ;;
309311
r)
310312
setrenderer $OPTARG ;;
311313
X)
@@ -370,5 +372,8 @@ if [ $path == "admin/data_dumps/download" ]; then
370372
else
371373
command="curl $curlopts -H \"Authorization: Basic $bridge_token\" -X $httpmethod \"https://$bridge_domain.bridgeapp.com/api/$path\" $formopts $outputrenderer $outputpath"
372374
fi
373-
374-
eval $command
375+
if [ "$sample" = true ]; then
376+
echo "$command"
377+
else
378+
eval $command
379+
fi

canvas/README

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ OPTIONS
4141
canvas_domain="<domain>"
4242
canvas_token="<token>"
4343

44-
4544
-d <domain>
4645
This option allows querying a specified domain,
4746
overriding the value set in the .inst config file.
@@ -106,6 +105,10 @@ OPTIONS
106105
Plain is always used when when -o <path> is used, even if color
107106
is explicitly specified in the command.
108107

108+
-s
109+
This command will output the complete curl command in a readable
110+
format. It will not execute the command.
111+
109112
-t <token>
110113
This option allows querying with a specified login password,
111114
overriding the value set in the .inst config file.

canvas/canvas

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ setrenderer() {
120120
local renderer="$1"
121121
case $renderer in
122122
"plain")
123-
outputrenderer="; echo -e \"\n\"" ;;
123+
outputrenderer="" ;;
124124
"color")
125125
outputrenderer="| json | pygmentize -l json" ;;
126126
*)
@@ -166,7 +166,7 @@ usage() {
166166

167167
version() {
168168
logo
169-
echo >&2 " canvas-cli version 0.3"
169+
echo >&2 " canvas-cli version 0.3.1"
170170
exit
171171
}
172172

@@ -366,7 +366,7 @@ elif [ $# -eq 0 ] && [ -f ~/.inst ]; then
366366
help
367367
else
368368
while [ $# -gt 0 ] && [ "$1" != "--" ]; do
369-
while getopts ":hlvcap:q:r:X:t:d:s:o:F:" opt; do
369+
while getopts ":hlvcasp:q:r:X:t:d:o:F:" opt; do
370370
case $opt in
371371
h)
372372
verbosehelp ;;
@@ -378,6 +378,8 @@ else
378378
setconfig ;;
379379
a)
380380
getpages=true ;;
381+
s)
382+
sample=true ;;
381383
q)
382384
setcount $OPTARG ;;
383385
p)
@@ -463,7 +465,11 @@ fi
463465

464466
while
465467
command="curl $curlopts -X $httpmethod \"https://$canvas_domain.instructure.com/$prefix$path$page$perpage\" $formopts $outputrenderer $outputpath"
466-
eval $command
468+
if [ "$sample" = true ]; then
469+
echo "$command"
470+
else
471+
eval $command
472+
fi
467473
(( $pageint < $pagecount ))
468474
do
469475
nextpage

catalog/README

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ OPTIONS
3939
catalog_domain="<domain>"
4040
catalog_token="<token>"
4141

42-
4342
-d <domain>
4443
This option allows querying a specified domain,
4544
overriding the value set in the .inst config file.
@@ -104,6 +103,10 @@ OPTIONS
104103
Plain is always used when when -o <path> is used, even if color
105104
is explicitly specified in the command.
106105

106+
-s
107+
This command will output the complete curl command in a readable
108+
format. It will not execute the command.
109+
107110
-t <token>
108111
This option allows querying with a specified login password,
109112
overriding the value set in the .inst config file.

catalog/catalog

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ setrenderer() {
120120
local renderer="$1"
121121
case $renderer in
122122
"plain")
123-
outputrenderer="; echo -e \"\n\"" ;;
123+
outputrenderer="" ;;
124124
"color")
125125
outputrenderer="| json | pygmentize -l json" ;;
126126
*)
@@ -166,7 +166,7 @@ usage() {
166166

167167
version() {
168168
logo
169-
echo >&2 " catalog-cli version 0.3.0"
169+
echo >&2 " catalog-cli version 0.3.1"
170170
exit
171171
}
172172

@@ -371,7 +371,7 @@ elif [ $# -eq 0 ] && [ -f ~/.inst ]; then
371371
help
372372
else
373373
while [ $# -gt 0 ] && [ "$1" != "--" ]; do
374-
while getopts ":hlvcar:X:t:d:o:p:q:F:" opt; do
374+
while getopts ":hlvcasr:X:t:d:o:p:q:F:" opt; do
375375
case $opt in
376376
h)
377377
verbosehelp ;;
@@ -393,6 +393,8 @@ else
393393
setoutput $OPTARG ;;
394394
a)
395395
getpages=true ;;
396+
s)
397+
sample=true ;;
396398
q)
397399
setcount $OPTARG ;;
398400
p)
@@ -456,8 +458,11 @@ fi
456458

457459
while
458460
command="curl $curlopts -X $httpmethod \"https://$catalog_domain.catalog.instructure.com/api/v1/$path$page$perpage\" $formopts $outputrenderer $outputpath"
459-
#eval $command
460-
#echo $command
461+
if [ "$sample" = true ]; then
462+
echo "$command"
463+
else
464+
eval $command
465+
fi
461466
(( $pageint < $pagecount ))
462467
do
463468
nextpage

commons/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ OPTIONS
8080
Plain is always used when when -o <path> is used, even if color
8181
is explicitly specified in the command.
8282

83+
-s
84+
This command will output the complete curl command in a readable
85+
format. It will not execute the command.
86+
8387
-t <token>
8488
This option allows querying with a specified login password,
8589
overriding the value set in the .inst config file.

commons/commons

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ setrenderer() {
111111
local renderer="$1"
112112
case $renderer in
113113
"plain")
114-
outputrenderer="; echo -e \"\n\"" ;;
114+
outputrenderer="" ;;
115115
"color")
116116
outputrenderer="| json | pygmentize -l json" ;;
117117
*)
@@ -155,7 +155,7 @@ usage() {
155155

156156
version() {
157157
logo
158-
echo >&2 " commons-cli version 0.2.3"
158+
echo >&2 " commons-cli version 0.3.1"
159159
exit
160160
}
161161

@@ -295,7 +295,7 @@ elif [ $# -eq 0 ] && [ -f ~/.inst ]; then
295295
help
296296
else
297297
while [ $# -gt 0 ] && [ "$1" != "--" ]; do
298-
while getopts ":hlvcr:x:X:t:d:o:f:F:" opt; do
298+
while getopts ":hlvcsr:x:X:t:d:o:f:F:" opt; do
299299
case $opt in
300300
h)
301301
verbosehelp ;;
@@ -305,6 +305,8 @@ else
305305
version ;;
306306
c)
307307
setconfig ;;
308+
s)
309+
sample=true ;;
308310
r)
309311
setrenderer $OPTARG ;;
310312
x)
@@ -390,7 +392,11 @@ if [[ $path == *"/download" ]]; then
390392
fi
391393

392394
command="curl $curlopts -H \"X-Session-ID: $session\" -X $httpmethod \"https://lor.instructure.com/api/$path\" $formopts $outputrenderer $outputpath"
393-
eval $command
395+
if [ "$sample" = true ]; then
396+
echo "$command"
397+
else
398+
eval $command
399+
fi
394400

395401
# DELETE SESSION ###############################################################
396402
# ##############################################################################

0 commit comments

Comments
 (0)