Warn about fzf if not installed (#27)

Fix #13
This commit is contained in:
Denis Isidoro 2019-09-21 17:43:17 -03:00 committed by GitHub
parent f1fee67a0f
commit c8764ae224
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 19 deletions

10
navi
View file

@ -3,14 +3,6 @@ set -euo pipefail
export SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "${SCRIPT_DIR}/src/arg.sh"
source "${SCRIPT_DIR}/src/cheat.sh"
source "${SCRIPT_DIR}/src/docs.sh"
source "${SCRIPT_DIR}/src/misc.sh"
source "${SCRIPT_DIR}/src/selection.sh"
source "${SCRIPT_DIR}/src/str.sh"
source "${SCRIPT_DIR}/src/ui.sh"
source "${SCRIPT_DIR}/src/main.sh"
##? Command cheatsheet tool
@ -24,4 +16,6 @@ source "${SCRIPT_DIR}/src/main.sh"
VERSION="0.6.1"
docs::eval "$@"
health::fzf
main "$@"

View file

@ -2,15 +2,7 @@
set -euo pipefail
export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
cd "$SCRIPT_DIR"
command_exists () {
type "$1" &> /dev/null
}
echoerr() {
echo "$@" 1>&2
}
source "${SCRIPT_DIR}/src/main.sh"
sha256() {
if command_exists sha256sum; then
@ -30,6 +22,8 @@ header() {
echo
}
cd "$SCRIPT_DIR"
header "git pull"
git pull

9
src/healthcheck.sh Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env bash
health::fzf() {
if ! command_exists fzf; then
echoerr "You need to install fzf before using navi"
echoerr "Please refer to https://github.com/junegunn/fzf for install instructions"
exit 66
fi
}

View file

@ -1,6 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail
source "${SCRIPT_DIR}/src/arg.sh"
source "${SCRIPT_DIR}/src/cheat.sh"
source "${SCRIPT_DIR}/src/docs.sh"
source "${SCRIPT_DIR}/src/healthcheck.sh"
source "${SCRIPT_DIR}/src/misc.sh"
source "${SCRIPT_DIR}/src/selection.sh"
source "${SCRIPT_DIR}/src/str.sh"
source "${SCRIPT_DIR}/src/ui.sh"
main() {
local readonly cheats="$(cheat::find)"
local readonly selection="$(ui::select "$cheats")"

View file

@ -4,3 +4,11 @@
dep() {
:
}
command_exists () {
type "$1" &> /dev/null
}
echoerr() {
echo "$@" 1>&2
}

View file

@ -1,7 +1,6 @@
#!/usr/bin/env bash
source <(
grep -v 'main ' "${SCRIPT_DIR}/navi" | sed -E "s|export.*|export SCRIPT_DIR=\"${SCRIPT_DIR}\"|")
source "${SCRIPT_DIR}/src/main.sh"
test::success() {
echo "Test passed!"