mirror of
https://github.com/denisidoro/navi.git
synced 2024-09-19 14:27:17 +03:00
parent
4792621b8c
commit
78638c67e4
2
navi
2
navi
@ -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.11.0"
|
VERSION="0.11.1"
|
||||||
NAVI_ENV="${NAVI_ENV:-prod}"
|
NAVI_ENV="${NAVI_ENV:-prod}"
|
||||||
|
|
||||||
opts::eval "$@"
|
opts::eval "$@"
|
||||||
|
@ -8,7 +8,6 @@ export SCRIPT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|||||||
files_to_lint() {
|
files_to_lint() {
|
||||||
find . -iname '*.sh'
|
find . -iname '*.sh'
|
||||||
find scripts/*
|
find scripts/*
|
||||||
find shell/*
|
|
||||||
echo "${SCRIPT_DIR}/test/run"
|
echo "${SCRIPT_DIR}/test/run"
|
||||||
echo "${SCRIPT_DIR}/navi"
|
echo "${SCRIPT_DIR}/navi"
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,12 @@ arg::next() {
|
|||||||
|
|
||||||
arg::deserialize() {
|
arg::deserialize() {
|
||||||
local arg="$1"
|
local arg="$1"
|
||||||
|
|
||||||
arg="${arg:1:${#arg}-2}"
|
arg="${arg:1:${#arg}-2}"
|
||||||
echo "$arg" | tr "${ARG_DELIMITER}" " " | tr "${ARG_DELIMITER_2}" "'" | tr "${ARG_DELIMITER_3}" '"'
|
echo "$arg" \
|
||||||
|
| tr "${ARG_DELIMITER}" " " \
|
||||||
|
| tr "${ARG_DELIMITER_2}" "'" \
|
||||||
|
| tr "${ARG_DELIMITER_3}" '"'
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: separation of concerns
|
# TODO: separation of concerns
|
||||||
|
@ -51,15 +51,15 @@ cheat::pretty() {
|
|||||||
/^%/ { tags=" ["substr($0, 3)"]"; next }
|
/^%/ { tags=" ["substr($0, 3)"]"; next }
|
||||||
/^#/ { print color(4, $0) color(60, tags); next }
|
/^#/ { print color(4, $0) color(60, tags); next }
|
||||||
/^\$/ { next }
|
/^\$/ { next }
|
||||||
NF { print color(7, $0) color(60, tags); next }'
|
NF { print color(7, $0) color(60, tags); next }'
|
||||||
}
|
}
|
||||||
|
|
||||||
cheat::_until_percentage() {
|
cheat::_until_percentage() {
|
||||||
awk 'BEGIN { count=0; }
|
awk 'BEGIN { count=0; }
|
||||||
|
|
||||||
/^%/ { if (count >= 1) exit;
|
/^%/ { if (count >= 1) exit;
|
||||||
else { count++; print $0; next; } }
|
else { count++; print $0; next; } }
|
||||||
{ print $0 }'
|
{ print $0 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
cheat::from_selection() {
|
cheat::from_selection() {
|
||||||
|
@ -46,7 +46,7 @@ coll::add() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
coll::reverse() {
|
coll::reverse() {
|
||||||
tac
|
str::reverse_lines "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
coll::set() {
|
coll::set() {
|
||||||
|
@ -29,7 +29,7 @@ selection::cmd_or_comment() {
|
|||||||
else
|
else
|
||||||
echo "$cheat" \
|
echo "$cheat" \
|
||||||
| grep "^${core}$" -B999 \
|
| grep "^${core}$" -B999 \
|
||||||
| tac \
|
| str::reverse_lines \
|
||||||
| str::last_paragraph_line
|
| str::last_paragraph_line
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
10
src/str.sh
10
src/str.sh
@ -35,3 +35,13 @@ str::index_last_occurrence() {
|
|||||||
|
|
||||||
awk 'BEGIN{FS=""}{ for(i=1;i<=NF;i++){ if($i=="'"$char"'"){ p=i } }}END{ print p }'
|
awk 'BEGIN{FS=""}{ for(i=1;i<=NF;i++){ if($i=="'"$char"'"){ p=i } }}END{ print p }'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
str::reverse_lines() {
|
||||||
|
if command_exists tac; then
|
||||||
|
tac
|
||||||
|
elif command_exists perl; then
|
||||||
|
perl -e 'print reverse <>'
|
||||||
|
else
|
||||||
|
awk '{a[i++]=$0} END {for (j=i-1; j>=0;) print a[j--] }'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
interpolation_one_word() {
|
interpolation_one_word() {
|
||||||
echo "curl http://mysite.com/<user>/profile" \
|
echo "curl http://mysite.com/<user>/profile" \
|
||||||
| arg::interpolate "user" "john" \
|
| arg::interpolate "user" "john" \
|
||||||
| test::equals "curl http://mysite.com/john/profile"
|
| test::equals "curl http://mysite.com/john/profile"
|
||||||
}
|
}
|
||||||
|
|
||||||
interpolation_multiple_words() {
|
interpolation_multiple_words() {
|
||||||
echo "cp <file> <new_file>" \
|
echo "cp <file> <new_file>" \
|
||||||
| arg::interpolate "file" "C:/Program Files/app/foo.exe" \
|
| arg::interpolate "file" "C:/Program Files/app/foo.exe" \
|
||||||
| arg::interpolate "new_file" "/mnt/c/Users/john/foo.exe" \
|
| arg::interpolate "new_file" "/mnt/c/Users/john/foo.exe" \
|
||||||
| test::equals 'cp "C:/Program Files/app/foo.exe" /mnt/c/Users/john/foo.exe'
|
| test::equals 'cp "C:/Program Files/app/foo.exe" /mnt/c/Users/john/foo.exe'
|
||||||
}
|
}
|
||||||
|
|
||||||
test::set_suite "arg"
|
test::set_suite "arg"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
existing() {
|
existing() {
|
||||||
platform::existing_command oasida fngo ni awk aoisdn oafm \
|
platform::existing_command oasida fngo ni awk aoisdn oafm \
|
||||||
| test::equals awk
|
| test::equals awk
|
||||||
}
|
}
|
||||||
|
|
||||||
test::set_suite "platform"
|
test::set_suite "platform"
|
||||||
|
Loading…
Reference in New Issue
Block a user