diff options
| author | Moritz Meißelbach <m.meisselbach@inpsyde.com> | 2019-11-28 14:50:22 +0100 |
|---|---|---|
| committer | Moritz Meißelbach <m.meisselbach@inpsyde.com> | 2019-11-28 14:50:22 +0100 |
| commit | 22182d980a2ebde89fe2970e11c39fbf8e4d6628 (patch) | |
| tree | ee2737f73f588f0658cf388b739123bc0dc8772b | |
| parent | b47903bc3e9bf4256feb6b1f4ca0da70824f159b (diff) | |
| download | sway-launcher-desktop-22182d980a2ebde89fe2970e11c39fbf8e4d6628.tar.gz sway-launcher-desktop-22182d980a2ebde89fe2970e11c39fbf8e4d6628.zip | |
Run list command in separate function for testability and interoperability
| -rwxr-xr-x | sway-launcher-desktop.sh | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 79ff1f2..4b21c7d 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -43,6 +43,10 @@ function describe() { echo "${description:-No description}" } +function provide() { + readarray -d ${DEL} -t PROVIDER_ARGS <<<${PROVIDERS[$1]} + eval "${PROVIDER_ARGS[0]}" +} function list-commands() { IFS=: read -ra path <<<"$PATH" for dir in "${path[@]}"; do @@ -165,7 +169,7 @@ function generate-command() { } case "$1" in -describe | entries | list-entries | list-commands | command-line | generate-command | purge) +describe | entries | list-entries | list-commands | command-line | generate-command | provide) "$@" exit ;; @@ -179,10 +183,7 @@ trap 'rm "$FZFPIPE"' EXIT INT (printf '%s' "${HIST_LINES[@]#* }" >>"$FZFPIPE") & # Iterate over providers and run their list-command -for PROVIDER in "${PROVIDERS[@]}"; do - readarray -d ${DEL} -t PROVIDER_ARGS <<<${PROVIDER} - (bash -c "${PROVIDER_ARGS[0]}" >>"$FZFPIPE") & -done +for PROVIDER_NAME in "${!PROVIDERS[@]}"; do (bash -c "${0} provide ${PROVIDER_NAME}" >>"$FZFPIPE") & done COMMAND_STR=$( fzf +s -x -d '\034' --nth ..3 --with-nth 3 \ |
