feat: pass subcommand

This commit is contained in:
ayo 2026-07-11 15:04:08 +02:00
parent c870f0df15
commit 70b2ce0cce
2 changed files with 19 additions and 15 deletions

27
ayo.sh
View file

@ -5,14 +5,17 @@
. ${scripts_dir}/functions.sh
{
# Sub-scripts read their subcommand from different positions, so forward args accordingly:
# $1-style (git, journal, mail, notes, tasks): pass "${@:2}" — drop the router word.
# $2-style (ai, display, conf): pass "$@" — they expect the router word as $1.
case $1 in
## SHORTCUTS
ja) # journal append
. ${scripts_dir}/journal.sh append "$@"
. ${scripts_dir}/journal.sh append "${@:2}"
;;
jt) # journal using typora
. ${scripts_dir}/journal.sh -t "$@"
. ${scripts_dir}/journal.sh -t "${@:2}"
;;
nd) # Notes diff
@ -22,22 +25,22 @@ case $1 in
. ${scripts_dir}/notes.sh sync
;;
nl) # Notes list
. ${scripts_dir}/notes.sh list "$@"
. ${scripts_dir}/notes.sh list "${@:2}"
;;
no) # Notes open
. ${scripts_dir}/notes.sh open "$@"
. ${scripts_dir}/notes.sh open "${@:2}"
;;
nr) # Notes remove
. ${scripts_dir}/notes.sh remove "$@"
. ${scripts_dir}/notes.sh remove "${@:2}"
;;
na) # Notes archive
. ${scripts_dir}/notes.sh archive "$@"
. ${scripts_dir}/notes.sh archive "${@:2}"
;;
nc) # Notes copy
. ${scripts_dir}/notes.sh copy "$@"
. ${scripts_dir}/notes.sh copy "${@:2}"
;;
nt) # Notes using typora
. ${scripts_dir}/notes.sh -t "$@"
. ${scripts_dir}/notes.sh -t "${@:2}"
;;
gd) # git diff
@ -63,7 +66,7 @@ case $1 in
. ${scripts_dir}/ai.sh "$@"
;;
m | mail)
. ${scripts_dir}/mail.sh "$@"
. ${scripts_dir}/mail.sh "${@:2}"
;;
d | display)
. ${scripts_dir}/display.sh "$@"
@ -75,16 +78,16 @@ case $1 in
. ${scripts_dir}/conf.sh "$@"
;;
g | git)
. ${scripts_dir}/git.sh "$@"
. ${scripts_dir}/git.sh "${@:2}"
;;
n | notes)
. ${scripts_dir}/notes.sh "$@"
. ${scripts_dir}/notes.sh "${@:2}"
;;
t | tasks)
TASKS_HOME="${tasks_dir}" TASKS_TEMPLATE="${tasks_template}" ${scripts_dir}/tasks "${@:2}"
;;
j | journal)
. ${scripts_dir}/journal.sh "$@"
. ${scripts_dir}/journal.sh "${@:2}"
;;
c | config)
echo 'Config script in-progress'

View file

@ -49,7 +49,8 @@ function createNote() {
}
function main() {
case "$2" in
# $1 = subcommand, $2 = its argument (matches git.sh / journal.sh convention)
case "$1" in
# DIFF: Show git diff of staged changes
diff|d)
cd "$notes_dir"
@ -89,7 +90,7 @@ function main() {
files=( "$notes_dir"/*.md )
if ! [ "$2" = "" ]; then
index=$((2-1))
index=$(($2-1))
open_file=${files[$index]}
editFile "$open_file"
else
@ -115,7 +116,7 @@ function main() {
files=( "$notes_dir"/*.md )
if ! [ "$2" = "" ]; then
index=$((2-1))
index=$(($2-1))
remove_file=${files[$index]}
echo "Removing $remove_file"
rm "$remove_file"