Run search as the default command

Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
Oliver Davies 2025-09-21 19:44:09 +01:00
parent a90870a747
commit 7e5afc2193

23
zet
View file

@ -14,16 +14,13 @@ Usage:
zet id QUERY... : Search for a zettel and display its ID zet id QUERY... : Search for a zettel and display its ID
zet print|p QUERY... : Search for a zettel and print it zet print|p QUERY... : Search for a zettel and print it
zet push : Push changes zet push : Push changes
zet search|s QUERY... : Print IDs and titles of zettels matching QUERY
zet view|v QUERY... : Search for a zettel and view it zet view|v QUERY... : Search for a zettel and view it
zet QUERY... : Print IDs and titles of zettels matching QUERY
EOF EOF
set -o errexit set -o errexit
COMMAND="${1:-}"
shift 1
SELECTED_ZET='' SELECTED_ZET=''
ZET_DIR=${ZET_DIR:-.} ZET_DIR=${ZET_DIR:-.}
ZET_LIST=() ZET_LIST=()
@ -132,17 +129,16 @@ get_title_from_file() {
} }
main() { main() {
if [[ -z "$COMMAND" ]]; then COMMAND="$1"
show_usage
exit 1
fi
case "$COMMAND" in case "$COMMAND" in
create | c) create | c)
shift 1
cmd_create "$@" cmd_create "$@"
;; ;;
edit | e) edit | e)
shift 1
cmd_edit "$@" cmd_edit "$@"
;; ;;
@ -151,10 +147,12 @@ main() {
;; ;;
id) id)
shift 1
cmd_id "$@" cmd_id "$@"
;; ;;
links | l) links | l)
shift 1
cmd_links "$@" cmd_links "$@"
;; ;;
@ -162,18 +160,13 @@ main() {
cmd_push cmd_push
;; ;;
search | s)
cmd_search "$@"
;;
view | v) view | v)
shift 1
cmd_view "$@" cmd_view "$@"
;; ;;
*) *)
echo "ERROR: $COMMAND" cmd_search "$@"
show_usage
exit 1
;; ;;
esac esac
} }