summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2019-12-06 14:24:14 -0300
committerGitHub <noreply@github.com>2019-12-06 14:24:14 -0300
commit42ac8dae9c5ee44a07b552eeb7bcfd9766f1f01a (patch)
treecdb113dafc80ccad8c3c83fad7e8bd7ea2b1a9ec
parent1c2dca32840167bdd1eb4af1701df00582982029 (diff)
Remove dep order from outputs (#163)v0.15.5
`: <foo> <bar>; echo <foo> <bar>` → `echo <foo> <bar>`
-rwxr-xr-xnavi2
-rw-r--r--src/cmd.sh2
-rw-r--r--src/ui.sh6
-rw-r--r--test/cheat_test.sh2
-rw-r--r--test/core.sh10
-rwxr-xr-xtest/run2
6 files changed, 20 insertions, 4 deletions
diff --git a/navi b/navi
index 609404e..1793f22 100755
--- a/navi
+++ b/navi
@@ -4,7 +4,7 @@ set -euo pipefail
export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)"
source "${NAVI_HOME}/src/main.sh"
-VERSION="0.15.4"
+VERSION="0.15.5"
NAVI_ENV="${NAVI_ENV:-prod}"
opts::eval "$@"
diff --git a/src/cmd.sh b/src/cmd.sh
index b5b92a9..f0bdd8e 100644
--- a/src/cmd.sh
+++ b/src/cmd.sh
@@ -46,7 +46,7 @@ cmd::finish() {
if [[ "$key" = "ctrl-y" ]]; then
clip::set "$cmd"
elif $print || [ -n "$unresolved_arg" ]; then
- echo "$cmd"
+ echo "$cmd" | ui::remove_dep_order
else
eval "$cmd"
fi
diff --git a/src/ui.sh b/src/ui.sh
index 6c984b0..8bd22ff 100644
--- a/src/ui.sh
+++ b/src/ui.sh
@@ -73,6 +73,10 @@ ui::width() {
fi
}
+ui::remove_dep_order() {
+ sed -E 's/^[^;]+; //'
+}
+
ui::print_preview() {
local -r selection="$1"
@@ -87,5 +91,5 @@ ui::print_preview() {
printf "\033[${comment_color}m# "; echo -n "$comment"
printf " \033[${tag_color}m["; echo -n "$tags"; echo "]"
printf "\033[${snippet_color}m"
- echo "$snippet"
+ echo "$snippet" | ui::remove_dep_order
} \ No newline at end of file
diff --git a/test/cheat_test.sh b/test/cheat_test.sh
index 4e8cc7e..17e2abe 100644
--- a/test/cheat_test.sh
+++ b/test/cheat_test.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
assert_docker_cheat() {
- cheat::find | grep -q "docker.cheat"
+ cheat::find | test::contains "docker.cheat"
}
test::set_suite "cheat"
diff --git a/test/core.sh b/test/core.sh
index 6d1f00a..cb3b2e7 100644
--- a/test/core.sh
+++ b/test/core.sh
@@ -53,6 +53,16 @@ test::equals() {
fi
}
+test::contains() {
+ local -r actual="$(cat)"
+ local -r regex="$(echo "${1:-}")"
+
+ if ! echo "$actual" | grep -qE "$regex"; then
+ log::error "Expected to contain '${regex}' but got '${actual}'"
+ return 2
+ fi
+}
+
test::finish() {
echo
if [ $SKIPPED -gt 0 ]; then
diff --git a/test/run b/test/run
index 661be7a..93f532b 100755
--- a/test/run
+++ b/test/run
@@ -6,6 +6,8 @@ source "${NAVI_HOME}/test/core.sh"
tests="$(find "$NAVI_HOME/test" -iname "${1:-}*_test.sh")"
+NAVI_PATH="${NAVI_HOME}/cheats"
+
for test in $tests; do
source "$test"
done