Remove dep order from outputs (#163)

`: <foo> <bar>; echo <foo> <bar>` → `echo <foo> <bar>`
This commit is contained in:
Denis Isidoro 2019-12-06 14:24:14 -03:00 committed by GitHub
parent 1c2dca3284
commit 42ac8dae9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 4 deletions

2
navi
View file

@ -4,7 +4,7 @@ set -euo pipefail
export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)" export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)"
source "${NAVI_HOME}/src/main.sh" source "${NAVI_HOME}/src/main.sh"
VERSION="0.15.4" VERSION="0.15.5"
NAVI_ENV="${NAVI_ENV:-prod}" NAVI_ENV="${NAVI_ENV:-prod}"
opts::eval "$@" opts::eval "$@"

View file

@ -46,7 +46,7 @@ cmd::finish() {
if [[ "$key" = "ctrl-y" ]]; then if [[ "$key" = "ctrl-y" ]]; then
clip::set "$cmd" clip::set "$cmd"
elif $print || [ -n "$unresolved_arg" ]; then elif $print || [ -n "$unresolved_arg" ]; then
echo "$cmd" echo "$cmd" | ui::remove_dep_order
else else
eval "$cmd" eval "$cmd"
fi fi

View file

@ -73,6 +73,10 @@ ui::width() {
fi fi
} }
ui::remove_dep_order() {
sed -E 's/^[^;]+; //'
}
ui::print_preview() { ui::print_preview() {
local -r selection="$1" local -r selection="$1"
@ -87,5 +91,5 @@ ui::print_preview() {
printf "\033[${comment_color}m# "; echo -n "$comment" printf "\033[${comment_color}m# "; echo -n "$comment"
printf " \033[${tag_color}m["; echo -n "$tags"; echo "]" printf " \033[${tag_color}m["; echo -n "$tags"; echo "]"
printf "\033[${snippet_color}m" printf "\033[${snippet_color}m"
echo "$snippet" echo "$snippet" | ui::remove_dep_order
} }

View file

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
assert_docker_cheat() { assert_docker_cheat() {
cheat::find | grep -q "docker.cheat" cheat::find | test::contains "docker.cheat"
} }
test::set_suite "cheat" test::set_suite "cheat"

View file

@ -53,6 +53,16 @@ test::equals() {
fi 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() { test::finish() {
echo echo
if [ $SKIPPED -gt 0 ]; then if [ $SKIPPED -gt 0 ]; then

View file

@ -6,6 +6,8 @@ source "${NAVI_HOME}/test/core.sh"
tests="$(find "$NAVI_HOME/test" -iname "${1:-}*_test.sh")" tests="$(find "$NAVI_HOME/test" -iname "${1:-}*_test.sh")"
NAVI_PATH="${NAVI_HOME}/cheats"
for test in $tests; do for test in $tests; do
source "$test" source "$test"
done done