Skip to content

Commit

Permalink
Fixing utils.functions-matching.diff(); v2.5.1
Browse files Browse the repository at this point in the history
This is a very important function in this library.
  • Loading branch information
kigster committed Sep 16, 2021
1 parent 4d2ad7e commit 66cb5b8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.0
2.5.1
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"compile-hero.disable-compile-files-on-did-save-code": true,
"shellcheck.enableQuickFix": true,
"workbench.colorTheme": "Popping and Locking",
"window.zoomLevel": 0,
"window.zoomLevel": 1,
"customPresentationMode.backup": {},
"gruvboxMaterial.jsson1Comments": false,
"git-graph.markdown": false
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[separator=—]
= Bashmatic® — BASH-based DSL helpers for humans, sysadmins, and fun.
// vim: ft=asciidoc
:author: Version v2.4.6
:author: Version v2.5.0
:doctype: book
:source-highlighter: rouge
:rouge-style: base16.monokai
Expand Down
Binary file modified README.pdf
Binary file not shown.
Binary file modified doc/USAGE.pdf
Binary file not shown.
8 changes: 6 additions & 2 deletions lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ util.rot13() {
}

alias rot13=util.rot13
__grep="${GrepCommand/ */}"
[[ -n ${__grep} && -x ${__grep} ]] || {
export GrepCommand="$(command -v grep) -E"
}

util.is-variable-defined() {
local var_name="$1"
Expand Down Expand Up @@ -211,11 +215,11 @@ util.functions-starting-with-csv() {
util.functions-matching() {
local prefix="${1}"
local extra_command=${2:-"cat"}
set | ${GrepCommand} '^${prefix}' | sedx 's/[\(\)]//g;' | /usr/bin/tr -d ' ' | /usr/bin/tr '\n' ' '
declare -f | ${GrepCommand} "^${prefix}" | sedx 's/[\(\)]//g;' | /usr/bin/tr -d ' ' | /usr/bin/tr '\n' ' '
}

util.functions-matching.diff() {
for m in "$@"; do
while true; do
[[ -z "$1" ]] && break
for e in $(util.functions-matching "${1}"); do
printf "${e/$1/}\n"
Expand Down
12 changes: 12 additions & 0 deletions test/util_test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ load test_helper
source lib/util.sh
source lib/user.sh
source lib/is.sh
source lib/db.sh
source lib/db_cli.sh
source lib/db_rails.sh
source lib/db_top.sh

set -e

Expand Down Expand Up @@ -67,3 +71,11 @@ moo() {
set -e
[ $code -ne 0 ]
}

@test "util.functions-matching.diff" {
set -e
local -a actions=($(util.functions-matching.diff db.actions. | sort))
local num=${#actions[@]}
[[ $num -gt 10 ]] &&
[[ "${actions[0]}" == "commands" ]]
}

0 comments on commit 66cb5b8

Please sign in to comment.