Skip to content

Commit f0529ff

Browse files
committed
ksau: Add -q option
1 parent 70759c7 commit f0529ff

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: ksau

+13-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ $(upline 5)"
169169
# Below function is copied from - https://gist.github.com/jaytaylor/5a90c49e0976aadfe0726a847ce58736
170170
# Credit to @jkishner for https://gist.github.com/jkishner/2fccb24640a27c2d7ac9
171171
function url_encode() {
172-
echo "$@" |
172+
builtin echo "$@" |
173173
sed \
174174
-e 's/%/%25/g' \
175175
-e 's/ /%20/g' \
@@ -220,6 +220,10 @@ upload() {
220220
echo -e "\n$(clearline)$(upline 1)$(clearline)$(upline 1)"
221221
echo "$(clearline) Upload Completed "
222222
echo "$(clearline) Download link - ${lightgreen}https://index.sauraj.eu.org/${url_folder}/${url_file}${normal} "
223+
224+
if [[ $KSAUOPT_QUIET == true ]]; then
225+
builtin echo "https://index.sauraj.eu.org/${url_folder}/${url_file}"
226+
fi
223227
}
224228

225229
help() {
@@ -228,6 +232,7 @@ ${aqua}Usage : ksau [-r] [OPTION]... [FILE]...${normal}
228232
229233
${aqua}Options:${normal}
230234
-r Add random string to the end of filename when uploading
235+
-q Suppress all output, printing only the link after upload is finished
231236
232237
Note that all options must be passed ${Red}BEFORE${normal} other arguments.
233238
@@ -296,12 +301,18 @@ version() {
296301
}
297302

298303
KSAUOPT_ADD_RAND_STR=false
304+
KSAUOPT_QUIET=false
299305

300-
while getopts "r" opt; do
306+
while getopts "rq" opt; do
301307
case $opt in
302308
r)
303309
KSAUOPT_ADD_RAND_STR=true
304310
;;
311+
q)
312+
KSAUOPT_QUIET=true
313+
# Override all echo call.
314+
echo() { true; }
315+
;;
305316
?)
306317
# Getopts already print error for us so just exit
307318
exit 1

0 commit comments

Comments
 (0)