Skip to content

Commit a7a3026

Browse files
committed
repo, screen and spinner modules updated & spinner ui degrade to increase performance
1 parent b2816c1 commit a7a3026

File tree

3 files changed

+49
-48
lines changed

3 files changed

+49
-48
lines changed

src/repo.sh

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ source "${Dir}"/ask.sh
1515
# source inspect.sh
1616
# source ask.sh
1717

18-
# repo.size(api) -> int
19-
# Used to get size of a repo.
20-
# Args:
21-
# api (str) > takes api of github repo. (eg: "OurCodeBase/bash-sdk")
22-
# Returns:
23-
# size (int) > gives you file size in MiB. (eg: 30)
18+
# repo.size(api) ~ int
19+
# Used to get size of a repo.
20+
#
21+
# ARGS:
22+
# - api (str): takes api of github repo. (eg: "OurCodeBase/bash-sdk")
23+
#
24+
# RETURNS:
25+
# - size (int): gives you file size in MiB. (eg: 30)
2426
repo.size(){
2527
inspect.is_func 'curl';
2628
local Api="$(echo "${1}" | awk '{print $1}')";
@@ -29,9 +31,10 @@ repo.size(){
2931
}
3032

3133
# repo.chart(apis)
32-
# Used to view info of given repositories.
33-
# Args:
34-
# apis (array) > takes array of repository api.
34+
# Used to view info of given repositories.
35+
#
36+
# ARGS:
37+
# - apis (array): takes array of repository api.
3538
repo.chart(){
3639
inspect.ScreenSize '50' '12';
3740
local ARGs=("${@}");
@@ -58,11 +61,12 @@ repo.chart(){
5861
return 0;
5962
}
6063

61-
# repo.clone(apis,*dirs)
62-
# Used to start cloning of a repository.
63-
# Args:
64-
# apis (array) > takes apis of github repo. (eg: OurCodeBase/bash-sdk)
65-
# dirs (array) > Optional: You can give directory path to clone to it.
64+
# repo.clone(apis,@dirs)
65+
# Used to start cloning of a repository.
66+
#
67+
# ARGS:
68+
# - apis (array): takes apis of github repo. (eg: OurCodeBase/bash-sdk)
69+
# - dirs (array,optional): You can give directory path to clone to it.
6670
repo.clone(){
6771
# required to run.
6872
inspect.is_func 'git';

src/screen.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#!/bin/bash
22

3-
# screen.cols() -> int
4-
# Gives you current columns count in terminal.
3+
# screen.cols() ~ int
4+
# Gives you current columns count in terminal.
55
screen.cols(){
66
# current columns in terminal.
77
stty size | awk '{print $2}'
88
}
99

10-
# screen.lines() -> int
11-
# Gives you current lines count in terminal.
10+
# screen.lines() ~ int
11+
# Gives you current lines count in terminal.
1212
screen.lines(){
1313
# current lines in terminal.
1414
stty size | awk '{print $1}'
1515
}
1616

17-
# screen.isSize(cols,lines) -> bool
18-
# Checks that screen has atleast given lines and columns.
19-
# Args:
20-
# cols (int) > takes columns as int.
21-
# lines (int) > takes lines as int.
17+
# screen.isSize(cols,lines) ~ bool
18+
# Checks that screen has atleast given lines and columns.
19+
#
20+
# ARGS:
21+
# - cols (int): takes columns as int.
22+
# - lines (int): takes lines as int.
2223
screen.isSize(){
2324
local ARGCols=${1};
2425
local ARGLines=${2};

src/spinner.sh

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#!/bin/bash
22

33
# Shorts:
4-
# spinner.start(use,subject)
5-
# run your functions.
6-
# spinner.stop
4+
# - spinner.start(use,subject)
5+
# - run your functions.
6+
# - spinner.stop
77

88
# Suppressed Variables
99
if (( 1<2 )); then
@@ -14,15 +14,7 @@ Genta="\033[1;35m";
1414
Green="\033[1;32m";
1515
Red="\033[1;31m";
1616
Yelo="\033[1;33m";
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}";
17+
# Global variables.
2618
CircleIcon="";
2719
Success="SUCCESS";
2820
Failure="FAILED";
@@ -36,7 +28,7 @@ Scribe=(
3628
fi
3729

3830
# spinner.setCursor(on~off)
39-
# Switch terminal cursor easily.
31+
# Switch terminal cursor easily.
4032
spinner.setCursor(){
4133
setterm -cursor "${1}";
4234
}
@@ -63,23 +55,27 @@ _spinner(){
6355
exit 1;
6456
};
6557
kill ${3} > /dev/null 2>&1
66-
echo -en "\b${Clear}";
67-
[[ $2 -eq 0 ]] &&
68-
echo -e "${StatusGreen} ${Success} ${Clear}" || {
69-
echo -e "${StatusRed} ${Failure} ${Clear}" &&
58+
echo -en "\b${Clear}";
59+
if [[ $2 -eq 0 ]]; then
60+
echo -e "[ ${Green}${Success}${Clear} ]";
61+
else
62+
echo -e "[ ${Red}${Failure}${Clear} ]";
63+
spinner.setCursor on;
7064
exit 1;
71-
};
65+
fi
7266
;;
7367
esac
7468
}
7569

7670
# spinner.start(use,subject)
77-
# Starts spinner to spin.
78-
# Args:
79-
# use (str) > takes process (eg: installing, processing).
80-
# subject (str) > takes subject (eg: file, function).
81-
# Means:
82-
# (use, subject) > (Processing 'Sleep')
71+
# Starts spinner to spin.
72+
#
73+
# ARGS:
74+
# - use (str): takes process (eg: installing, processing).
75+
# - subject (str): takes subject (eg: file, function).
76+
#
77+
# EG:
78+
# - (use,subject): (Processing 'Sleep')
8379
spinner.start(){
8480
[[ ${#} -eq 2 ]] ||
8581
{ echo "error: 'missing args'" && return 1; };
@@ -91,7 +87,7 @@ spinner.start(){
9187
}
9288

9389
# spinner.stop()
94-
# Stops spinner to spin.
90+
# Stops spinner to spin.
9591
spinner.stop(){
9692
_spinner stop ${?} ${_SpinnerPid};
9793
unset ${_SpinnerPid};

0 commit comments

Comments
 (0)