feat: pass subcommand
This commit is contained in:
parent
c870f0df15
commit
70b2ce0cce
2 changed files with 19 additions and 15 deletions
27
ayo.sh
27
ayo.sh
|
|
@ -5,14 +5,17 @@
|
||||||
. ${scripts_dir}/functions.sh
|
. ${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
|
case $1 in
|
||||||
## SHORTCUTS
|
## SHORTCUTS
|
||||||
|
|
||||||
ja) # journal append
|
ja) # journal append
|
||||||
. ${scripts_dir}/journal.sh append "$@"
|
. ${scripts_dir}/journal.sh append "${@:2}"
|
||||||
;;
|
;;
|
||||||
jt) # journal using typora
|
jt) # journal using typora
|
||||||
. ${scripts_dir}/journal.sh -t "$@"
|
. ${scripts_dir}/journal.sh -t "${@:2}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
nd) # Notes diff
|
nd) # Notes diff
|
||||||
|
|
@ -22,22 +25,22 @@ case $1 in
|
||||||
. ${scripts_dir}/notes.sh sync
|
. ${scripts_dir}/notes.sh sync
|
||||||
;;
|
;;
|
||||||
nl) # Notes list
|
nl) # Notes list
|
||||||
. ${scripts_dir}/notes.sh list "$@"
|
. ${scripts_dir}/notes.sh list "${@:2}"
|
||||||
;;
|
;;
|
||||||
no) # Notes open
|
no) # Notes open
|
||||||
. ${scripts_dir}/notes.sh open "$@"
|
. ${scripts_dir}/notes.sh open "${@:2}"
|
||||||
;;
|
;;
|
||||||
nr) # Notes remove
|
nr) # Notes remove
|
||||||
. ${scripts_dir}/notes.sh remove "$@"
|
. ${scripts_dir}/notes.sh remove "${@:2}"
|
||||||
;;
|
;;
|
||||||
na) # Notes archive
|
na) # Notes archive
|
||||||
. ${scripts_dir}/notes.sh archive "$@"
|
. ${scripts_dir}/notes.sh archive "${@:2}"
|
||||||
;;
|
;;
|
||||||
nc) # Notes copy
|
nc) # Notes copy
|
||||||
. ${scripts_dir}/notes.sh copy "$@"
|
. ${scripts_dir}/notes.sh copy "${@:2}"
|
||||||
;;
|
;;
|
||||||
nt) # Notes using typora
|
nt) # Notes using typora
|
||||||
. ${scripts_dir}/notes.sh -t "$@"
|
. ${scripts_dir}/notes.sh -t "${@:2}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
gd) # git diff
|
gd) # git diff
|
||||||
|
|
@ -63,7 +66,7 @@ case $1 in
|
||||||
. ${scripts_dir}/ai.sh "$@"
|
. ${scripts_dir}/ai.sh "$@"
|
||||||
;;
|
;;
|
||||||
m | mail)
|
m | mail)
|
||||||
. ${scripts_dir}/mail.sh "$@"
|
. ${scripts_dir}/mail.sh "${@:2}"
|
||||||
;;
|
;;
|
||||||
d | display)
|
d | display)
|
||||||
. ${scripts_dir}/display.sh "$@"
|
. ${scripts_dir}/display.sh "$@"
|
||||||
|
|
@ -75,16 +78,16 @@ case $1 in
|
||||||
. ${scripts_dir}/conf.sh "$@"
|
. ${scripts_dir}/conf.sh "$@"
|
||||||
;;
|
;;
|
||||||
g | git)
|
g | git)
|
||||||
. ${scripts_dir}/git.sh "$@"
|
. ${scripts_dir}/git.sh "${@:2}"
|
||||||
;;
|
;;
|
||||||
n | notes)
|
n | notes)
|
||||||
. ${scripts_dir}/notes.sh "$@"
|
. ${scripts_dir}/notes.sh "${@:2}"
|
||||||
;;
|
;;
|
||||||
t | tasks)
|
t | tasks)
|
||||||
TASKS_HOME="${tasks_dir}" TASKS_TEMPLATE="${tasks_template}" ${scripts_dir}/tasks "${@:2}"
|
TASKS_HOME="${tasks_dir}" TASKS_TEMPLATE="${tasks_template}" ${scripts_dir}/tasks "${@:2}"
|
||||||
;;
|
;;
|
||||||
j | journal)
|
j | journal)
|
||||||
. ${scripts_dir}/journal.sh "$@"
|
. ${scripts_dir}/journal.sh "${@:2}"
|
||||||
;;
|
;;
|
||||||
c | config)
|
c | config)
|
||||||
echo 'Config script in-progress'
|
echo 'Config script in-progress'
|
||||||
|
|
|
||||||
7
notes.sh
7
notes.sh
|
|
@ -49,7 +49,8 @@ function createNote() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
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: Show git diff of staged changes
|
||||||
diff|d)
|
diff|d)
|
||||||
cd "$notes_dir"
|
cd "$notes_dir"
|
||||||
|
|
@ -89,7 +90,7 @@ function main() {
|
||||||
files=( "$notes_dir"/*.md )
|
files=( "$notes_dir"/*.md )
|
||||||
|
|
||||||
if ! [ "$2" = "" ]; then
|
if ! [ "$2" = "" ]; then
|
||||||
index=$((2-1))
|
index=$(($2-1))
|
||||||
open_file=${files[$index]}
|
open_file=${files[$index]}
|
||||||
editFile "$open_file"
|
editFile "$open_file"
|
||||||
else
|
else
|
||||||
|
|
@ -115,7 +116,7 @@ function main() {
|
||||||
files=( "$notes_dir"/*.md )
|
files=( "$notes_dir"/*.md )
|
||||||
|
|
||||||
if ! [ "$2" = "" ]; then
|
if ! [ "$2" = "" ]; then
|
||||||
index=$((2-1))
|
index=$(($2-1))
|
||||||
remove_file=${files[$index]}
|
remove_file=${files[$index]}
|
||||||
echo "Removing $remove_file"
|
echo "Removing $remove_file"
|
||||||
rm "$remove_file"
|
rm "$remove_file"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue