Skip to content

Commit

Permalink
updated ui in chart of repo
Browse files Browse the repository at this point in the history
  • Loading branch information
OurCodeBase committed Jan 12, 2024
1 parent f17821a commit ff071ab
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,47 @@ source "${Dir}"/ask.sh
# source inspect.sh
# source ask.sh

# repo.size(api) -> str
# repo.size(api) -> int
# Used to get size of a repo.
# Args:
# api (str) > takes api of github repo. (eg: "OurCodeBase/bash-sdk")
# Returns:
# size (int) > gives you file size in MB. (eg: 30 MB)
# size (int) > gives you file size in MiB. (eg: 30)
repo.size(){
# checking curl is installed or not.
inspect.is_func curl;
inspect.is_func 'curl';
local Api="$(echo "${1}" | awk '{print $1}')";
local UriSize=$(curl "https://api.github.com/repos/${Api}" 2> /dev/null | grep size | head -1 | tr -dc '[:digit:]');
echo $(( UriSize/1024 ));
return;
local ApiSize=$(curl "https://api.github.com/repos/${Api}" 2> /dev/null | grep size | head -1 | tr -dc '[:digit:]');
echo $(( ApiSize/1024 ));
}

# repo.chart(apis)
# Used to view info of given repositories.
# Args:
# apis (array) > takes array of repository api.
repo.chart(){
echo;
inspect.ScreenSize 81 38;
inspect.ScreenSize '50' '12';
local ARGs=("${@}");
local PuraSize=0;
setCursor off;
say.success "📦 Getting Information Repository";
echo -e "
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ INFORMATION REPOSITORY ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
┃ REPOSITORY NAME REPOSITORY SIZE ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
echo -e "
╭─ Clone ──────────────────────────────────────╮";
echo -e " │ │";
printf " │ %-34s %-7s │\n" 'Repository' 'Size';
printf " │ %-34s %-7s │\n" '──────────────────────────────────' '───────';
for ARG in "${ARGs[@]}"
do
local Api="$(echo "${ARG}" | awk '{print $1}')";
local UriSize="$(repo.size "${ARG}")";
printf " ${Green}%-36s${Clear} ${Yelo}%8s${Clear} \n" "${Api}" "${UriSize}";
echo -e " ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
local ApiSize="$(repo.size "${ARG}")";
printf " ${Green}%-34s${Clear} ${Yelo}%3s${Clear} %-3s │\n" "${Api}" "${ApiSize}" 'MiB';
local PuraSize=$(( PuraSize+ApiSize ));
done
echo;
echo -e " │ │";
echo -e " ╰──────────────────────────────────────────────╯\n";
echo -e " ╭─ TOTAL ────────────────────╮";
printf " │ %14s: ${Green}%4s${Clear} %3s │\n" "Cloning Size" "${PuraSize}" 'MiB';
echo -e " ╰────────────────────────────╯";
setCursor on;
return;
return 0;
}

# repo.clone(apis,*dirs)
Expand All @@ -65,7 +65,7 @@ repo.chart(){
# dirs (array) > Optional: You can give directory path to clone to it.
repo.clone(){
# required to run.
inspect.is_func git;
inspect.is_func 'git';
# function starts here
local ARGs=("${@}");
# printing chart.
Expand All @@ -75,14 +75,14 @@ repo.clone(){
for ARG in "${ARGs[@]}"
do
local Api="$(echo "${ARG}" | awk '{print $1}')";
local Uri="$(echo "${ARG}" | awk '{print $2}')"; # Uri=Path
local ApiPath="$(echo "${ARG}" | awk '{print $2}')";
local Url="https://github.com/${Api}.git";
# spinner started.
spinner.start "Cloning" "${Api}";
# started cloning.
[[ -z "${Uri}" ]] &&
[[ -z "${ApiPath}" ]] &&
git clone --depth=1 "${Url}" 2> /dev/null ||
git clone --depth=1 "${Url}" "${Uri}" 2> /dev/null;
git clone --depth=1 "${Url}" "${ApiPath}" 2> /dev/null;
# stopped spinner.
spinner.stop;
done
Expand Down

0 comments on commit ff071ab

Please sign in to comment.