[styler] Remove optional rg dependency
rg does not give noticeable speed improvements, simply remove the command from styler and stick wich grep for each use.
This commit is contained in:
parent
8635b580bd
commit
d8b5c067fb
1 changed files with 5 additions and 19 deletions
|
@ -8,20 +8,6 @@ readonly PROCESSOR_PATH="$BASE_PATH/processors"
|
||||||
|
|
||||||
readonly VERSION="0.4.1"
|
readonly VERSION="0.4.1"
|
||||||
|
|
||||||
# ensures that some grep-like program is available, prefers rg
|
|
||||||
setgrepper() {
|
|
||||||
if command -v rg 1>/dev/null 2>&1; then
|
|
||||||
GREPPER="rg"
|
|
||||||
elif command -v grep 1>/dev/null 2>&1; then
|
|
||||||
GREPPER="grep"
|
|
||||||
else
|
|
||||||
notify-send "grep missing" "styler needs grep, or preferably rg to work."
|
|
||||||
echo "grep missing!" "styler needs grep, or preferably rg to work."
|
|
||||||
exit 127
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
setgrepper
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local cmd=""
|
local cmd=""
|
||||||
local ret=0
|
local ret=0
|
||||||
|
@ -116,7 +102,7 @@ get_processors() {
|
||||||
for processor in "$package"/*; do
|
for processor in "$package"/*; do
|
||||||
[[ -e "$processor" ]] || break
|
[[ -e "$processor" ]] || break
|
||||||
[[ -f "$processor" ]] || break
|
[[ -f "$processor" ]] || break
|
||||||
if ${GREPPER} -q -e '/theme_[[:alnum:]]\{1,\}$' <<<"$processor"; then
|
if grep -q -e '/theme_[[:alnum:]]\{1,\}$' <<<"$processor"; then
|
||||||
printf "%s\n" "$(basename -- "$processor")"
|
printf "%s\n" "$(basename -- "$processor")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -180,7 +166,7 @@ _fetch_universal_themes() {
|
||||||
local filtered
|
local filtered
|
||||||
for t in $unique; do
|
for t in $unique; do
|
||||||
for p in $packages; do
|
for p in $packages; do
|
||||||
if ! echo "$themes" | ${GREPPER} -qe "^.*$p.*$t.*$" -; then
|
if ! echo "$themes" | grep -qe "^.*$p.*$t.*$" -; then
|
||||||
themes="$(echo "$themes" | sed "/$t/d")"
|
themes="$(echo "$themes" | sed "/$t/d")"
|
||||||
unique="$(echo "$unique" | sed "/$t/d")"
|
unique="$(echo "$unique" | sed "/$t/d")"
|
||||||
break
|
break
|
||||||
|
@ -261,7 +247,7 @@ set_theme() {
|
||||||
appext=$(sed -e 's|^[A-Za-z0-9-]\{1,\}/base16-||' <<<"$pkg")
|
appext=$(sed -e 's|^[A-Za-z0-9-]\{1,\}/base16-||' <<<"$pkg")
|
||||||
|
|
||||||
# Compares application extension with existing processors and runs the appropriate processor if found
|
# Compares application extension with existing processors and runs the appropriate processor if found
|
||||||
processor=$(find "$PROCESSOR_PATH" -type f | ${GREPPER} -e "theme_$appext")
|
processor=$(find "$PROCESSOR_PATH" -type f | grep -e "theme_$appext")
|
||||||
if [[ -f "$processor" ]]; then
|
if [[ -f "$processor" ]]; then
|
||||||
"$processor" "$PACKAGE_PATH" "$pkg" "$theme" "$permanent"
|
"$processor" "$PACKAGE_PATH" "$pkg" "$theme" "$permanent"
|
||||||
else
|
else
|
||||||
|
@ -315,9 +301,9 @@ download() {
|
||||||
|
|
||||||
# if package has patter name/base16-program, put it in packages; if name/process16-program put it in processors
|
# if package has patter name/base16-program, put it in packages; if name/process16-program put it in processors
|
||||||
# if none of the above, assume it's a processor but warn the user
|
# if none of the above, assume it's a processor but warn the user
|
||||||
if ${GREPPER} -q -e '^[0-9A-Za-z-]\{1,\}/base16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then
|
if grep -q -e '^[0-9A-Za-z-]\{1,\}/base16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then
|
||||||
git clone "$repo" "$PACKAGE_PATH/$pkg"
|
git clone "$repo" "$PACKAGE_PATH/$pkg"
|
||||||
elif ${GREPPER} -q -e '^[0-9A-Za-z-]\{1,\}/process16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then
|
elif grep -q -e '^[0-9A-Za-z-]\{1,\}/process16-[0-9A-Za-z-]\{1,\}$' <<<"$pkg"; then
|
||||||
git clone "$repo" "$PROCESSOR_PATH/$pkg"
|
git clone "$repo" "$PROCESSOR_PATH/$pkg"
|
||||||
else
|
else
|
||||||
echo "Package does not fit default naming scheme of packages/processors. Assuming it is a processor but please check manually."
|
echo "Package does not fit default naming scheme of packages/processors. Assuming it is a processor but please check manually."
|
||||||
|
|
Loading…
Reference in a new issue