@@ -15,47 +15,47 @@ source "${Dir}"/ask.sh
15
15
# source inspect.sh
16
16
# source ask.sh
17
17
18
- # repo.size(api) -> str
18
+ # repo.size(api) -> int
19
19
# Used to get size of a repo.
20
20
# Args:
21
21
# api (str) > takes api of github repo. (eg: "OurCodeBase/bash-sdk")
22
22
# Returns:
23
- # size (int) > gives you file size in MB . (eg: 30 MB )
23
+ # size (int) > gives you file size in MiB . (eg: 30)
24
24
repo.size (){
25
- # checking curl is installed or not.
26
- inspect.is_func curl;
25
+ inspect.is_func ' curl' ;
27
26
local Api=" $( echo " ${1} " | awk ' {print $1}' ) " ;
28
- local UriSize=$( curl " https://api.github.com/repos/${Api} " 2> /dev/null | grep size | head -1 | tr -dc ' [:digit:]' ) ;
29
- echo $(( UriSize/ 1024 )) ;
30
- return ;
27
+ local ApiSize=$( curl " https://api.github.com/repos/${Api} " 2> /dev/null | grep size | head -1 | tr -dc ' [:digit:]' ) ;
28
+ echo $(( ApiSize/ 1024 )) ;
31
29
}
32
30
33
31
# repo.chart(apis)
34
32
# Used to view info of given repositories.
35
33
# Args:
36
34
# apis (array) > takes array of repository api.
37
35
repo.chart (){
38
- echo ;
39
- inspect.ScreenSize 81 38;
36
+ inspect.ScreenSize ' 50' ' 12' ;
40
37
local ARGs=(" ${@ } " );
38
+ local PuraSize=0;
41
39
setCursor off;
42
- say.success " 📦 Getting Information Repository" ;
43
- echo -e "
44
- ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
45
- ┃ INFORMATION REPOSITORY ┃
46
- ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
47
- ┃ REPOSITORY NAME REPOSITORY SIZE ┃
48
- ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛" ;
40
+ echo -e "
41
+ ╭─ Clone ──────────────────────────────────────╮" ;
42
+ echo -e " │ │" ;
43
+ printf " │ %-34s %-7s │\n" ' Repository' ' Size' ;
44
+ printf " │ %-34s %-7s │\n" ' ──────────────────────────────────' ' ───────' ;
49
45
for ARG in " ${ARGs[@]} "
50
46
do
51
47
local Api=" $( echo " ${ARG} " | awk ' {print $1}' ) " ;
52
- local UriSize =" $( repo.size " ${ARG} " ) " ;
53
- printf " ┃ ${Green} %-36s ${Clear} ${Yelo} %8s ${Clear} ┃ \n" " ${Api} " " ${UriSize} " ;
54
- echo -e " ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ " ;
48
+ local ApiSize =" $( repo.size " ${ARG} " ) " ;
49
+ printf " │ ${Green} %-34s ${Clear} ${Yelo} %3s ${Clear} %-3s │ \n" " ${Api} " " ${ApiSize} " ' MiB ' ;
50
+ local PuraSize= $(( PuraSize + ApiSize )) ;
55
51
done
56
- echo ;
52
+ echo -e " │ │" ;
53
+ echo -e " ╰──────────────────────────────────────────────╯\n" ;
54
+ echo -e " ╭─ TOTAL ────────────────────╮" ;
55
+ printf " │ %14s: ${Green} %4s${Clear} %3s │\n" " Cloning Size" " ${PuraSize} " ' MiB' ;
56
+ echo -e " ╰────────────────────────────╯" ;
57
57
setCursor on;
58
- return ;
58
+ return 0 ;
59
59
}
60
60
61
61
# repo.clone(apis,*dirs)
@@ -65,7 +65,7 @@ repo.chart(){
65
65
# dirs (array) > Optional: You can give directory path to clone to it.
66
66
repo.clone (){
67
67
# required to run.
68
- inspect.is_func git;
68
+ inspect.is_func ' git' ;
69
69
# function starts here
70
70
local ARGs=(" ${@ } " );
71
71
# printing chart.
@@ -75,14 +75,14 @@ repo.clone(){
75
75
for ARG in " ${ARGs[@]} "
76
76
do
77
77
local Api=" $( echo " ${ARG} " | awk ' {print $1}' ) " ;
78
- local Uri =" $( echo " ${ARG} " | awk ' {print $2}' ) " ; # Uri=Path
78
+ local ApiPath =" $( echo " ${ARG} " | awk ' {print $2}' ) " ;
79
79
local Url=" https://github.com/${Api} .git" ;
80
80
# spinner started.
81
81
spinner.start " Cloning" " ${Api} " ;
82
82
# started cloning.
83
- [[ -z " ${Uri } " ]] &&
83
+ [[ -z " ${ApiPath } " ]] &&
84
84
git clone --depth=1 " ${Url} " 2> /dev/null ||
85
- git clone --depth=1 " ${Url} " " ${Uri } " 2> /dev/null;
85
+ git clone --depth=1 " ${Url} " " ${ApiPath } " 2> /dev/null;
86
86
# stopped spinner.
87
87
spinner.stop;
88
88
done
0 commit comments