summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2022-11-20 23:47:26 +0800
committerGuangxiong Lin <[email protected]>2022-11-20 23:47:26 +0800
commitf58eb61d80dfc39e4ed33ca0680bd92736d4b452 (patch)
treed574d691fde6eba7541108fc1347b410f38d618c
parentc9ea66f4d1b162d86bb4c1a5fc285c6d95500330 (diff)
downloadwd-f58eb61d80dfc39e4ed33ca0680bd92736d4b452.tar.gz
wd-f58eb61d80dfc39e4ed33ca0680bd92736d4b452.tar.bz2
wd-f58eb61d80dfc39e4ed33ca0680bd92736d4b452.zip
Improve default subcommand implementation
-rwxr-xr-xwd9
1 files changed, 4 insertions, 5 deletions
diff --git a/wd b/wd
index 5880f98..3da1519 100755
--- a/wd
+++ b/wd
@@ -78,12 +78,11 @@ cmd_git () {
cd "$WD_NOTES_DIR" && git "$@"
}
-if [ "$#" -eq 0 ]; then
- "$PROGRAM" "$WD_DEFAULT_SUBCOMMAND"
- exit 0
-fi
-case "$1" in
+subcommand="$WD_DEFAULT_SUBCOMMAND"
+[ "$#" -ne 0 ] && subcommand="$1"
+
+case "$subcommand" in
help|--help|-h) shift; cmd_usage "$@";;
version|--version|-v) shift; cmd_version "$@";;
journal|j) shift; cmd_journal "$@";;