@@ -15,47 +15,47 @@ source "${Dir}"/ask.sh
1515# source inspect.sh
1616# source ask.sh
1717
18- # repo.size(api) -> str
18+ # repo.size(api) -> int
1919# Used to get size of a repo.
2020# Args:
2121# api (str) > takes api of github repo. (eg: "OurCodeBase/bash-sdk")
2222# Returns:
23- # size (int) > gives you file size in MB . (eg: 30 MB )
23+ # size (int) > gives you file size in MiB . (eg: 30)
2424repo.size (){
25- # checking curl is installed or not.
26- inspect.is_func curl;
25+ inspect.is_func ' curl' ;
2726 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 )) ;
3129}
3230
3331# repo.chart(apis)
3432# Used to view info of given repositories.
3533# Args:
3634# apis (array) > takes array of repository api.
3735repo.chart (){
38- echo ;
39- inspect.ScreenSize 81 38;
36+ inspect.ScreenSize ' 50' ' 12' ;
4037 local ARGs=(" ${@ } " );
38+ local PuraSize=0;
4139 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" ' ──────────────────────────────────' ' ───────' ;
4945 for ARG in " ${ARGs[@]} "
5046 do
5147 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 )) ;
5551 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 " ╰────────────────────────────╯" ;
5757 setCursor on;
58- return ;
58+ return 0 ;
5959}
6060
6161# repo.clone(apis,*dirs)
@@ -65,7 +65,7 @@ repo.chart(){
6565# dirs (array) > Optional: You can give directory path to clone to it.
6666repo.clone (){
6767 # required to run.
68- inspect.is_func git;
68+ inspect.is_func ' git' ;
6969 # function starts here
7070 local ARGs=(" ${@ } " );
7171 # printing chart.
@@ -75,14 +75,14 @@ repo.clone(){
7575 for ARG in " ${ARGs[@]} "
7676 do
7777 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}' ) " ;
7979 local Url=" https://github.com/${Api} .git" ;
8080 # spinner started.
8181 spinner.start " Cloning" " ${Api} " ;
8282 # started cloning.
83- [[ -z " ${Uri } " ]] &&
83+ [[ -z " ${ApiPath } " ]] &&
8484 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;
8686 # stopped spinner.
8787 spinner.stop;
8888 done
0 commit comments