aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <chaffinach+git@protonmail.ch>2022-01-13 20:21:26 +0000
committerMatthew Lemon <chaffinach+git@protonmail.ch>2022-01-13 20:21:26 +0000
commit715ee043aff6a0d1367ac3dac0fd7daa35976248 (patch)
tree4b62fb21d1c2fe683f325ebe59119a88c3223adb
parent2422775a9a6f7d134f494cf15e23bd7359212cf9 (diff)
added a usage func and cleanup
-rwxr-xr-xgrepjournal13
1 files changed, 7 insertions, 6 deletions
diff --git a/grepjournal b/grepjournal
index 1ec671a..4d68892 100755
--- a/grepjournal
+++ b/grepjournal
@@ -2,12 +2,14 @@
# Search ~/Notes/journal for a term and return as a markdown list sorted by date.
-# very bad way to check the params passed in...
-# [[ -z "$2" ]] && [[ -n "$1" ]] && searchterm="$1"
-# [[ -n "$2" ]] && [[ -n "$1" ]] && searchterm="$1" && flag="$2"
+function usage {
+ echo
+ echo "Usage: grepjournal [WORD] [-i (case insensitve)] [-h (display this help)]"
+ echo " Searches for WORD within all files within ~/Notes/journal. Displayed sorted by date."
+}
if [[ $# -eq 0 ]]; then
- echo "Do grepnotes -h"; exit 1
+ usage; exit 1
fi
while [[ $# -gt 0 ]]; do
@@ -15,8 +17,7 @@ while [[ $# -gt 0 ]]; do
flag="-i"
shift
elif [[ "$1" = "-h" ]] || [[ "$1" = "--help" ]]; then
- echo "Usage: grepjournal [WORD] [-i (case insensitve)] [-h (display this help)]"
- echo " Searches for WORD within all files within ~/Notes/journal. Displayed sorted by date."
+ usage
exit
else
searchterm=$1