Skip to content

Commit

Permalink
Correctly escape % in cheatsheets (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
denisidoro authored Sep 27, 2019
1 parent 4bf6c98 commit d55b572
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion navi
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
Expand Down
2 changes: 1 addition & 1 deletion src/dict.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions test/dict_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand Down Expand Up @@ -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
Expand Down
14 changes: 12 additions & 2 deletions test/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions test/playground.cheat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d55b572

Please sign in to comment.