mirror of
https://github.com/denisidoro/navi
synced 2025-02-16 12:38:28 +00:00
Allow variable names to include dashes and spaces (#97)
Based on https://github.com/denisidoro/navi/pull/95 by @engrravijain Fixes #60
This commit is contained in:
parent
2aa07c2ce1
commit
d04dfc1003
6 changed files with 19 additions and 1 deletions
7
scripts/playground
Executable file
7
scripts/playground
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
export NAVI_PATH="${SCRIPT_DIR}/test:${SCRIPT_DIR}/cheats"
|
||||
|
||||
"${SCRIPT_DIR}/navi" "$@"
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ARG_REGEX="<[0-9a-zA-Z_]+>"
|
||||
ARG_REGEX="<[a-zA-Z_]+([- ]?\w+)*>"
|
||||
ARG_DELIMITER="\f"
|
||||
ARG_DELIMITER_2="\v"
|
||||
ARG_DELIMITER_3="\r"
|
||||
|
|
|
@ -38,6 +38,10 @@ handler::main() {
|
|||
break
|
||||
fi
|
||||
|
||||
escaped_arg="$(echo "$arg" | tr '-' '_' | tr ' ' '_')"
|
||||
cmd="$(echo "$cmd" | sed "s|<${arg}>|<${escaped_arg}>|g")"
|
||||
arg="$escaped_arg"
|
||||
|
||||
value="$(arg::pick "$arg" "$cheat" || echo "")"
|
||||
if [ -z "$value" ]; then
|
||||
echoerr "Unable to fetch suggestions for '$arg'!"
|
||||
|
|
|
@ -6,6 +6,7 @@ source "${SCRIPT_DIR}/src/main.sh"
|
|||
source "${SCRIPT_DIR}/test/log.sh"
|
||||
|
||||
opts::eval "$@"
|
||||
TEST_DIR="${SCRIPT_DIR}/test"
|
||||
|
||||
PASSED=0
|
||||
FAILED=0
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
# this should be the first test. single and double quotes + newlines
|
||||
echo <x> <y>
|
||||
|
||||
# variable names
|
||||
echo <x> <foo> <foo_bar> <lorem-ipsum> <dolor sit>
|
||||
|
||||
# use %
|
||||
coll::new 1 2 3 | xargs -I% echo "hello %"
|
||||
|
||||
|
|
|
@ -11,7 +11,10 @@ check_all_vars() {
|
|||
done
|
||||
}
|
||||
|
||||
path="$NAVI_PATH"
|
||||
NAVI_PATH="${NAVI_PATH}:${TEST_DIR}"
|
||||
for cheat in $(cheat::find); do
|
||||
test::run "All variables in $(basename $cheat) are valid" \
|
||||
'check_all_vars "$cheat"'
|
||||
done
|
||||
NAVI_PATH="$path"
|
Loading…
Add table
Reference in a new issue