Add list function to styler
Can list available themes, packages, and processors. Invoked by `styler list` and then the intended target. When invoked without any valid target will remind the user to supply one. `list`, `--list`, `-l` are aliases and perform the same function. Examples: `styler list themes` `styler --list packages` `styler -l processors`
This commit is contained in:
parent
2ee8453750
commit
4838aecb75
1 changed files with 29 additions and 1 deletions
|
@ -1,7 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
readonly BASE_PATH="${STYLER_DATA_PATH:-${XDG_DATA_HOME:-$HOME/.local/share}/styler}"
|
readonly BASE_PATH="${STYLER_DATA_PATH:-${XDG_DATA_HOME:-$HOME/.local/share}/styler}"
|
||||||
readonly DEBUG="${STYLER_ENABLE_DEBUG_MODE:-false}"
|
|
||||||
|
|
||||||
readonly PACKAGE_PATH="$BASE_PATH/packages"
|
readonly PACKAGE_PATH="$BASE_PATH/packages"
|
||||||
readonly PROCESSOR_PATH="$BASE_PATH/processors"
|
readonly PROCESSOR_PATH="$BASE_PATH/processors"
|
||||||
|
@ -14,6 +13,9 @@ main() {
|
||||||
-s | --set | set)
|
-s | --set | set)
|
||||||
cmd="set_theme"
|
cmd="set_theme"
|
||||||
;;
|
;;
|
||||||
|
-l | --list | list)
|
||||||
|
cmd="list"
|
||||||
|
;;
|
||||||
-v | --version | version)
|
-v | --version | version)
|
||||||
printf "Program theming script.\n\n©Marty Oehme\n\nVersion: 0.1.0\n"
|
printf "Program theming script.\n\n©Marty Oehme\n\nVersion: 0.1.0\n"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -75,6 +77,13 @@ get_processors() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# retrieves all installed themes from all packages, appends applications they exist for
|
||||||
|
get_themes() {
|
||||||
|
local themes
|
||||||
|
themes=$(find "$PACKAGE_PATH" -type f -name 'base16-*')
|
||||||
|
echo "$themes" | sed "s/.*\\/base16-//" | sed "s/\\..*//" | sort | uniq
|
||||||
|
}
|
||||||
|
|
||||||
set_theme() {
|
set_theme() {
|
||||||
local theme="$1"
|
local theme="$1"
|
||||||
|
|
||||||
|
@ -112,4 +121,23 @@ set_theme() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list() {
|
||||||
|
local selected="$1"
|
||||||
|
|
||||||
|
case "$selected" in
|
||||||
|
packages)
|
||||||
|
get_packages
|
||||||
|
;;
|
||||||
|
processors)
|
||||||
|
get_processors
|
||||||
|
;;
|
||||||
|
themes)
|
||||||
|
get_themes
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Please select one of packages | processors | themes to list."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
main "$@"
|
main "$@"
|
||||||
|
|
Loading…
Reference in a new issue