💄 Added simple arg check and reformatted
This commit is contained in:
parent
6bd4aee6e6
commit
c3d50af36e
1 changed files with 10 additions and 6 deletions
16
scripts/dye
16
scripts/dye
|
|
@ -17,7 +17,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
printhelp() {
|
printhelp() {
|
||||||
cat << EOM
|
cat <<EOM
|
||||||
usage: dye [-h|-r] [color_code]
|
usage: dye [-h|-r] [color_code]
|
||||||
options:
|
options:
|
||||||
-x hex code to rgb
|
-x hex code to rgb
|
||||||
|
|
@ -30,8 +30,8 @@ EOM
|
||||||
}
|
}
|
||||||
|
|
||||||
hex_to_rgb() {
|
hex_to_rgb() {
|
||||||
: "${1/\#}"
|
: "${1/\#/}"
|
||||||
((r=16#${_:0:2},g=16#${_:2:2},b=16#${_:4:2}))
|
((r = 16#${_:0:2}, g = 16#${_:2:2}, b = 16#${_:4:2}))
|
||||||
printf '%s\n' "rgba($r, $g, $b)"
|
printf '%s\n' "rgba($r, $g, $b)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,17 +46,21 @@ error() {
|
||||||
|
|
||||||
dependencycheck() {
|
dependencycheck() {
|
||||||
local dep missingdependencies=0
|
local dep missingdependencies=0
|
||||||
for dep in "$@" ; do
|
for dep in "$@"; do
|
||||||
if ! command -v "$dep" &> /dev/null ; then
|
if ! command -v "$dep" &>/dev/null; then
|
||||||
error "dependency not met: $dep"
|
error "dependency not met: $dep"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ $missingdependencies -gt 0 ]] ; then
|
if [[ $missingdependencies -gt 0 ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
if [[ "$#" -lt 1 ]]; then
|
||||||
|
printhelp
|
||||||
|
fi
|
||||||
|
|
||||||
while getopts ":x:r:?" arg; do
|
while getopts ":x:r:?" arg; do
|
||||||
case $arg in
|
case $arg in
|
||||||
x)
|
x)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue