Skip to content

Commit f17821a

Browse files
committed
ui updated in chart of package, arrow of say and spinners status
1 parent 117340e commit f17821a

File tree

3 files changed

+50
-45
lines changed

3 files changed

+50
-45
lines changed

src/package.sh

+24-23
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ source "${Dir}"/os.sh
2424
# install (str) > install to get package installed size.
2525
# package (str) > takes package (eg: python,nodejs).
2626
# Returns:
27-
# size (int) > Gives you size in MBs.
27+
# size (int) > Gives you size in MiBs.
2828
# Usage:
2929
# pkg.size(dnload,package) > Gives you package file size.
3030
# pkg.size(install,package) > Gives you package installed size.
@@ -35,14 +35,14 @@ pkg.size(){
3535
return 1;
3636
fi
3737
case "${1}" in
38-
'dnload') local SizeVar="$(apt show "${2}" 2> /dev/null | grep 'Download-Size:')";;
39-
'install') local SizeVar="$(apt show "${2}" 2> /dev/null | grep 'Installed-Size:')";;
38+
'dnload') local SizeSource="$(apt show "${2}" 2> /dev/null | grep 'Download-Size:')";;
39+
'install') local SizeSource="$(apt show "${2}" 2> /dev/null | grep 'Installed-Size:')";;
4040
esac
41-
local Size="$(echo "${SizeVar}" | awk '{print $2}')";
42-
local SizeUnit="$(echo "${SizeVar}" | awk '{print $3}')";
43-
# converting decimals to integers.
41+
local Size="$(echo "${SizeSource}" | awk '{print $2}')";
42+
local SizeUnit="$(echo "${SizeSource}" | awk '{print $3}')";
43+
# convert decimals to integers.
4444
local Size="${Size%%.*}";
45-
# checking unit of package.
45+
# check unit of package.
4646
case "${SizeUnit}" in
4747
'MB') echo "${Size}";;
4848
'kB') echo "$(( Size/1024 ))";;
@@ -57,22 +57,20 @@ pkg.size(){
5757
# Args:
5858
# pkgs (array) > takes array of packages.
5959
pkg.chart(){
60-
inspect.ScreenSize '96' '12';
60+
inspect.ScreenSize '62' '12';
6161
# this takes all packages as arg.
6262
local ARGs=("${@}");
6363
# total content file size of all packages.
6464
local PuraSizeDL=0;
6565
# total installed size of all packages.
6666
local PuraSizeIN=0;
67+
# turn off cursor.
6768
setCursor off;
68-
echo;
69-
say.success "📦 Getting Information Packages";
70-
echo -e "
71-
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
72-
┃ INFORMATION PACKAGES ┃
73-
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
74-
┃ PACKAGE NAME VERSION DOWNLOAD INSTALLED ┃
75-
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
69+
echo -e "
70+
╭─ Packages ─────────────────────────────────────────────╮";
71+
echo -e " │ │";
72+
printf " │ %-25s %-10s %-7s %-7s │\n" 'Package' 'Version' 'DLSize' 'INSize';
73+
printf " │ %-25s %-10s %-7s %-7s │\n" '─────────────────────────' '──────────' '───────' '───────';
7674
for ARG in "${ARGs[@]}"
7775
do
7876
# declare database variable.
@@ -85,18 +83,21 @@ pkg.chart(){
8583
local PackageSizeDL="$(pkg.size 'dnload' "${ARG}")";
8684
# declare package installed size variable.
8785
local PackageSizeIN="$(pkg.size 'install' "${ARG}")";
88-
printf "${Green}%-13s${Clear} ${Yelo}%10s${Clear} ${Yelo}%-4s${Clear} %-2s ${Yelo}%-4s${Clear} %-2s ┃\n" "${PackageVar}" "${PackageVersion}" "${PackageSizeDL}" "MB" "${PackageSizeIN}" "MB";
89-
echo -e " ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
86+
printf "${Green}%-25s${Clear} ${Yelo}%-10s${Clear} ${Yelo}%3s${Clear} %-3s ${Yelo}%3s${Clear} %-3s │\n" "${PackageVar}" "${PackageVersion}" "${PackageSizeDL}" 'MiB' "${PackageSizeIN}" 'MiB';
9087
# Adding dl sizes of all packages.
9188
local PuraSizeDL=$(( PuraSizeDL + PackageSizeDL ));
9289
# Adding ins sizes of all packages.
9390
local PuraSizeIN=$(( PuraSizeIN + PackageSizeIN ));
9491
done
95-
# print total data.
96-
printf " ┃ [ ${Yelo}%5s${Clear} ] ─────────────────────────────────> ${Yelo}%6s${Clear} %-2s ${Yelo}%6s${Clear} %-2s ┃" "TOTAL" "${PuraSizeDL}" "MB" "${PuraSizeIN}" "MB"
97-
echo -e "\n ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛";
98-
echo;
92+
echo -e " │ │";
93+
echo -e " ╰────────────────────────────────────────────────────────╯\n";
94+
echo -e " ╭─ TOTAL ────────────────────╮";
95+
printf " │ %14s: ${Green}%4s${Clear} %3s │\n" "Download Size" "${PuraSizeDL}" 'MiB';
96+
printf " │ %14s: ${Yelo}%4s${Clear} %3s │\n" "Installed Size" "${PuraSizeIN}" 'MiB';
97+
echo -e " ╰────────────────────────────╯";
98+
# turn on cursor.
9999
setCursor on;
100+
# return function.
100101
return;
101102
}
102103

@@ -128,4 +129,4 @@ pkg.install(){
128129
fi
129130
echo;
130131
return;
131-
}
132+
}

src/say.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ _status(){
8080
else local String+="${Uri} ";
8181
fi
8282
done
83-
echo -e "${StatusColor} INFO ${Clear} > ${String}";
83+
echo -e "${StatusColor} INFO ${Clear} ${String}";
8484
return 0;
8585
}
8686

@@ -108,9 +108,9 @@ say.success(){
108108
# status (int) > takes exit code.
109109
say.checkStatus(){
110110
if [[ "${1}" == 0 ]]; then
111-
echo -e " -> ${StatusGreen} SUCCESS ${Clear}";
111+
echo -e " ${StatusGreen} SUCCESS ${Clear}";
112112
else
113-
echo -e " -> ${StatusRed} FAILED ${Clear}";
113+
echo -e " ${StatusRed} FAILED ${Clear}";
114114
exit 1;
115115
fi
116116
}

src/spinner.sh

+23-19
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,33 @@
55
# run your functions.
66
# spinner.stop
77

8+
# Suppressed Variables
9+
if (( 1<2 )); then
810
# Colors
9-
if (( 2>1 )); then
1011
Clear="\033[0m";
1112
Blue="\033[1;34m";
1213
Genta="\033[1;35m";
1314
Green="\033[1;32m";
1415
Red="\033[1;31m";
1516
Yelo="\033[1;33m";
16-
fi
17-
18-
# Global Variables
19-
if (( 2>1 )); then
20-
icon="";
21-
success="SUCCESS";
22-
error="FAILED";
17+
Gora="\033[1;97m"
18+
# BG Colors.
19+
BGRed="\033[1;41m";
20+
BGGreen="\033[1;42m";
21+
BGYelo="\033[1;43m";
22+
# Status Colors.
23+
StatusRed="${BGRed}${Gora}";
24+
StatusGreen="${BGGreen}${Gora}";
25+
StatusYelo="${BGYelo}${Gora}";
26+
CircleIcon="";
27+
Success="SUCCESS";
28+
Failure="FAILED";
2329
list=(
24-
"${Blue}${icon}${Green}${icon}${Yelo}${icon}${Red}${icon}${Genta}${icon} "
25-
" ${Green}${icon}${Yelo}${icon}${Red}${icon}${Genta}${icon}${Blue}${icon} "
26-
" ${Red}${icon}${Genta}${icon}${Yelo}${icon}${Blue}${icon}${Green}${icon} "
27-
" ${Genta}${icon}${Blue}${icon}${Green}${Yelo}${icon}${icon}${Red}${icon} "
28-
" ${Blue}${icon}${Green}${icon}${Red}${icon}${Yelo}${icon}${Genta}${icon}"
30+
"${Blue}${CircleIcon}${Green}${CircleIcon}${Yelo}${CircleIcon}${Red}${CircleIcon}${Genta}${CircleIcon} "
31+
" ${Green}${CircleIcon}${Yelo}${CircleIcon}${Red}${CircleIcon}${Genta}${CircleIcon}${Blue}${CircleIcon} "
32+
" ${Red}${CircleIcon}${Genta}${CircleIcon}${Yelo}${CircleIcon}${Blue}${CircleIcon}${Green}${CircleIcon} "
33+
" ${Genta}${CircleIcon}${Blue}${CircleIcon}${Green}${Yelo}${CircleIcon}${CircleIcon}${Red}${CircleIcon} "
34+
" ${Blue}${CircleIcon}${Green}${CircleIcon}${Red}${CircleIcon}${Yelo}${CircleIcon}${Genta}${CircleIcon}"
2935
)
3036
fi
3137

@@ -57,14 +63,13 @@ _spinner(){
5763
exit 1
5864
fi
5965
kill ${3} > /dev/null 2>&1
60-
echo -en "\b${Clear} -> ["
66+
echo -en "\b${Clear} "
6167
if [[ $2 -eq 0 ]]; then
62-
echo -en " ${Green}${success}${Clear} "
68+
echo -e "${StatusGreen} ${Success} ${Clear}"
6369
else
64-
echo -en " ${Red}${error}${Clear} "
70+
echo -e "${StatusRed} ${Failure} ${Clear}"
6571
exit 1;
6672
fi
67-
echo -e "${Clear}]"
6873
;;
6974
*)
7075
echo "error: invalid args, try again with {start/stop}"
@@ -86,7 +91,6 @@ spinner.start(){
8691
return 1;
8792
fi
8893
local uri="${1} '${Green}${2}${Clear}'..."
89-
# required cmds.
9094
spinner.setCursor off
9195
_spinner start "${uri}" &
9296
_spinner_pid="${!}"
@@ -99,4 +103,4 @@ spinner.stop(){
99103
_spinner stop ${?} ${_spinner_pid};
100104
unset ${_spinner_pid};
101105
spinner.setCursor on
102-
}
106+
}

0 commit comments

Comments
 (0)