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