Skip to content

Commit 3db1b0c

Browse files
committed
ksau: Bump to version 1.5.1 (Stable).
1 parent 1cdac1e commit 3db1b0c

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

README.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ksau dependencies
3131

3232
### To upload
3333
```
34-
ksau upload <filename> <folder to upload>
34+
ksau upload [FILE] [FOLDER] # Uploads the given file to the given folder on index.
3535
#Example - ksau upload test.txt Public
3636
```
3737

@@ -46,19 +46,34 @@ ksau version
4646
```
4747
## Usage
4848
```
49-
upload <filename> <folder to upload>${normal} : Uploads the given file to the given folder.
50-
setup : Recquired while using first time.
51-
update : Fetch and install latest version available.
52-
dependencies : Installs recquired dependencies.
53-
help : To get this message.
54-
version: To get version info.
49+
Usage : ksau [OPTION]... [FILE]...
50+
51+
upload [FILE] [FOLDER] : Uploads the given file to the given folder
52+
on index.
53+
54+
upload -r [FILE] [FOLDER] : Uploads the given file to the given folder
55+
but with new filename with random strings
56+
at last (before extension if present).
57+
58+
setup : Recquired while using first time.
59+
60+
update : Fetch and install latest version available.
61+
62+
dependencies : Installs recquired dependencies.
63+
64+
help : To get this message.
65+
66+
version : To get version info.
67+
68+
Example : ksau upload test.txt Public
69+
5570
```
5671

5772
### Abuse alert
5873
Please don't abuse, we have limited storage.
5974
Also I'm sharing my configs just for community use and I get nothing from it.
6075

6176
### Create Your Own
62-
Just change your `rclone config` and `index link` in `ksau` (L40 & L71).
77+
Just change your `rclone config` and `index link` in `ksau`.
6378

6479
### Tool By @Ksauraj (@noobyysauraj)

ksau

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ Cyan='\033[0;36m' # Cyan
1616
White='\033[0;37m' # White
1717

1818
set -o pipefail
19-
#readonly file="$2"
20-
#readonly u_folder="$3"
2119
readonly status_dir="$(mktemp -d)"
2220

2321
trap "rm -rf $status_dir" EXIT
@@ -74,18 +72,23 @@ setup () {
7472
echo "Setup Completed"
7573
}
7674

75+
# Generates new filename with random strings at last (before extension if present).
76+
# new name for 'myfile.txt' -> 'myfile-78e11b8c.txt'
77+
# new name for 'myfile' -> 'myfile-78e11b8c'
7778
add_random_string() {
7879
local filename="$1"
7980
local extension="${filename##*.}"
8081
local name="${filename%.*}"
8182
local random_string="$(date +%s | sha256sum | base64 | head -c 8)"
82-
if [ "$extension" == "$filename" ]; then
83-
new_filename="$name-$random_string"
83+
if [ -z "$extension" ]; then
84+
new_filename="$name-$random_string"
8485
else
85-
new_filename="$name-$random_string.$extension"
86+
new_filename="$name-$random_string.$extension"
8687
fi
8788
}
8889

90+
# Simple progressbar animation.
91+
# Usage : progress_bar ${percentage} ${upload_speed} $(eta) ${status}
8992
progress_bar() {
9093
if [ "$(tput cols)" -lt 84 ]; then
9194
[ -z $1 ] && set -- "(Starting)" "..." "..." "..."
@@ -118,6 +121,7 @@ progress_bar() {
118121
fi
119122
}
120123

124+
# Upload file to give folder and use new filename if -r argument was passed and printing out new animation.
121125
rclone_progress_bar() {
122126
tput civis
123127
echo "Starting download..."
@@ -137,6 +141,8 @@ rclone_progress_bar() {
137141
done #|| echo -ne "\rDownload Can't be completed, Check download link." && tput cnorm && exit 1
138142
tput cnorm
139143
}
144+
145+
# Final part of animation if upload was succesfull.
140146
end_animation() {
141147
tput civis
142148

@@ -207,6 +213,7 @@ function url_encode() {
207213
-e 's/~/%7e/g'
208214
}
209215

216+
# rclone_progress_bar -> progress_bar -> end_animation -> Print dowload link.
210217
upload () {
211218
echo "Initializing process, might take up to 10 seconds..."
212219
rclone_progress_bar
@@ -224,20 +231,29 @@ upload () {
224231

225232
help () {
226233
echo "
234+
${aqua}Usage : ksau [OPTION]... [FILE]...${normal}
235+
236+
${aqua}upload [FILE] [FOLDER]${normal} : Uploads the given file to the given folder
237+
on index.
238+
239+
${aqua}upload -r [FILE] [FOLDER]${normal} : Uploads the given file to the given folder
240+
but with new filename with random strings
241+
at last (before extension if present).
242+
243+
${aqua}setup${normal} : Recquired while using first time.
227244
228-
${aqua}Usage : ksau <options> <params>${normal}
245+
${aqua}update${normal} : Fetch and install latest version
246+
available.
229247
230-
${aqua}upload <filename> <folder to upload>${normal} : Uploads the given file to the given folder.
231-
${aqua}setup${normal} : Recquired while using first time.
232-
${aqua}update${normal} : Fetch and install latest version available.
233-
${aqua}dependencies${normal} : Installs recquired dependencies.
234-
${aqua}help${normal} : To get this message.
235-
${aqua}version${normal} : To get version info.
248+
${aqua}dependencies${normal} : Installs recquired dependencies.
249+
250+
${aqua}help${normal} : To get this message.
251+
252+
${aqua}version${normal} : To get version info.
236253
237254
Example : ${lightgreen}ksau upload test.txt Public
238255
239256
${orange}Tool By Sauraj (@Ksauraj)${normal}
240-
241257
"
242258
}
243259

@@ -254,7 +270,7 @@ update () {
254270
}
255271

256272
version () {
257-
echo "${orange}Version - 1.5 (Stable) ${normal}"
273+
echo "${orange}Version - 1.5.1 (Stable) ${normal}"
258274
}
259275

260276
if [[ $1 == "upload" ]]; then

0 commit comments

Comments
 (0)