summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2019-09-27 16:53:31 -0300
committerGitHub <noreply@github.com>2019-09-27 16:53:31 -0300
commitd55b5725d46212b87864ad4bbf3ca4188553d0bc (patch)
tree20f91f2f8bebb3e4aed6b0318d3124c789642f0a
parent4bf6c981f4aab75bcd0404a5039c391afc76ee53 (diff)
Correctly escape % in cheatsheets (#94)v0.10.1
-rwxr-xr-xnavi2
-rw-r--r--src/dict.sh2
-rw-r--r--test/dict_test.sh8
-rw-r--r--test/integration_test.sh14
-rw-r--r--test/playground.cheat3
5 files changed, 25 insertions, 4 deletions
diff --git a/navi b/navi
index 6a3ed5d..44fcc23 100755
--- a/navi
+++ b/navi
@@ -35,7 +35,7 @@ source "${SCRIPT_DIR}/src/main.sh"
##? full docs
##? Please refer to the README at https://github.com/denisidoro/navi
-VERSION="0.10.0"
+VERSION="0.10.1"
NAVI_ENV="${NAVI_ENV:-prod}"
opts::eval "$@"
diff --git a/src/dict.sh b/src/dict.sh
index dc20955..04aefe0 100644
--- a/src/dict.sh
+++ b/src/dict.sh
@@ -41,7 +41,7 @@ dict::assoc() {
local -r input="$(cat)"
if [ -z $key ]; then
- printf "$input"
+ printf "$(echo "$input" | tr '%' '\v')" | tr '\v' '%'
return
fi
diff --git a/test/dict_test.sh b/test/dict_test.sh
index d268153..150c415 100644
--- a/test/dict_test.sh
+++ b/test/dict_test.sh
@@ -19,6 +19,13 @@ dict_assoc() {
| test::equals "foo: 42"
}
+dict_assoc_perc() {
+ dict::new \
+ | dict::assoc "foo" "42 %" bar "% 7" \
+ | dict::get bar \
+ | test::equals "% 7"
+}
+
dict_assoc_multiple() {
dict::new \
| dict::assoc "foo" "42" "bar" "5" \
@@ -102,6 +109,7 @@ dict_update() {
test::set_suite "dict"
test::run "We can assoc a value" dict_assoc
+test::run "We can assoc values with %" dict_assoc_perc
test::run "We can assoc multiple values" dict_assoc_multiple
test::skip "We can assoc a nested value" dict_assoc_nested
test::run "We can dissoc a value" dict_dissoc
diff --git a/test/integration_test.sh b/test/integration_test.sh
index 3b7055e..fd5ba98 100644
--- a/test/integration_test.sh
+++ b/test/integration_test.sh
@@ -38,10 +38,20 @@ assert_query() {
| test::equals "2 12"
}
+export HAS_FZF="$(command_exists fzf && echo true || echo false)"
+
+test::fzf() {
+ if $HAS_FZF; then
+ test::run "$@"
+ else
+ test::skip "$@"
+ fi
+}
+
test::set_suite "integration"
export -f fzf_mock
test::run "version" assert_version
test::run "help" assert_help
test::run "home" assert_home
-test::skip "best" assert_best # FZF setup needed in CircleCI
-test::skip "query" assert_query # FZF setup needed in CircleCI
+test::fzf "best" assert_best # FZF setup needed in CircleCI
+test::fzf "query" assert_query # FZF setup needed in CircleCI
diff --git a/test/playground.cheat b/test/playground.cheat
index 29acd98..f451a71 100644
--- a/test/playground.cheat
+++ b/test/playground.cheat
@@ -3,6 +3,9 @@
# this should be the first test. single and double quotes + newlines
echo <x> <y>
+# use %
+coll::new 1 2 3 | xargs -I% echo "hello %"
+
# return a constant number
echo 42