Correctly escape % in cheatsheets (#94)

This commit is contained in:
Denis Isidoro 2019-09-27 16:53:31 -03:00 committed by GitHub
parent 4bf6c981f4
commit d55b5725d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 4 deletions

2
navi
View file

@ -35,7 +35,7 @@ source "${SCRIPT_DIR}/src/main.sh"
##? full docs ##? full docs
##? Please refer to the README at https://github.com/denisidoro/navi ##? Please refer to the README at https://github.com/denisidoro/navi
VERSION="0.10.0" VERSION="0.10.1"
NAVI_ENV="${NAVI_ENV:-prod}" NAVI_ENV="${NAVI_ENV:-prod}"
opts::eval "$@" opts::eval "$@"

View file

@ -41,7 +41,7 @@ dict::assoc() {
local -r input="$(cat)" local -r input="$(cat)"
if [ -z $key ]; then if [ -z $key ]; then
printf "$input" printf "$(echo "$input" | tr '%' '\v')" | tr '\v' '%'
return return
fi fi

View file

@ -19,6 +19,13 @@ dict_assoc() {
| test::equals "foo: 42" | 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_assoc_multiple() {
dict::new \ dict::new \
| dict::assoc "foo" "42" "bar" "5" \ | dict::assoc "foo" "42" "bar" "5" \
@ -102,6 +109,7 @@ dict_update() {
test::set_suite "dict" test::set_suite "dict"
test::run "We can assoc a value" dict_assoc 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::run "We can assoc multiple values" dict_assoc_multiple
test::skip "We can assoc a nested value" dict_assoc_nested test::skip "We can assoc a nested value" dict_assoc_nested
test::run "We can dissoc a value" dict_dissoc test::run "We can dissoc a value" dict_dissoc

View file

@ -38,10 +38,20 @@ assert_query() {
| test::equals "2 12" | 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" test::set_suite "integration"
export -f fzf_mock export -f fzf_mock
test::run "version" assert_version test::run "version" assert_version
test::run "help" assert_help test::run "help" assert_help
test::run "home" assert_home test::run "home" assert_home
test::skip "best" assert_best # FZF setup needed in CircleCI test::fzf "best" assert_best # FZF setup needed in CircleCI
test::skip "query" assert_query # FZF setup needed in CircleCI test::fzf "query" assert_query # FZF setup needed in CircleCI

View file

@ -3,6 +3,9 @@
# this should be the first test. single and double quotes + newlines # this should be the first test. single and double quotes + newlines
echo <x> <y> echo <x> <y>
# use %
coll::new 1 2 3 | xargs -I% echo "hello %"
# return a constant number # return a constant number
echo 42 echo 42