refactor(notes): clean up; wrap login in main function
This commit is contained in:
parent
3f2f90b1c9
commit
5969c69bab
1 changed files with 128 additions and 129 deletions
45
notes.sh
45
notes.sh
|
@ -1,15 +1,9 @@
|
|||
#! /usr/bin/bash
|
||||
|
||||
## notes management
|
||||
|
||||
# Load config
|
||||
. ${HOME}/ayo.conf
|
||||
. ${scripts_dir}/functions.sh
|
||||
|
||||
# TODO: write log for echoes with >>>
|
||||
|
||||
command=$1
|
||||
|
||||
getopts "t" typora; #check if -t flag is given
|
||||
|
||||
function editFile() {
|
||||
|
@ -55,18 +49,19 @@ function createNote() {
|
|||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
||||
## DIFF
|
||||
if [ "$1" = "diff" ] || [ "$1" = "d" ]; then
|
||||
## DIFF
|
||||
if [ "$1" = "diff" ] || [ "$1" = "d" ]; then
|
||||
cd $notes_dir
|
||||
git add .
|
||||
git diff --staged .
|
||||
## SYNC notes in directory
|
||||
elif [ "$1" = "sync" ] || [ "$1" = "s" ]; then
|
||||
## SYNC notes in directory
|
||||
elif [ "$1" = "sync" ] || [ "$1" = "s" ]; then
|
||||
notesSync
|
||||
|
||||
## LIST notes in directory
|
||||
elif [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
||||
## LIST notes in directory
|
||||
elif [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
||||
echo "ACTIVE NOTES: "
|
||||
notesSync
|
||||
if ! [ "$2" = "" ]; then
|
||||
|
@ -80,8 +75,8 @@ elif [ "$1" = "list" ] || [ "$1" = "l" ]; then
|
|||
echo "$index) $file"
|
||||
done
|
||||
|
||||
## OPEN a note from a list
|
||||
elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
||||
## OPEN a note from a list
|
||||
elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
||||
notesSync
|
||||
files=( $notes_dir/*.md )
|
||||
|
||||
|
@ -105,8 +100,8 @@ elif [ "$1" = "open" ] || [ "$1" = "o" ]; then
|
|||
done
|
||||
fi
|
||||
|
||||
## REMOVE a note from a list
|
||||
elif [ "$1" = "remove" ] || [ "$1" = "rm" ]; then
|
||||
## REMOVE a note from a list
|
||||
elif [ "$1" = "remove" ] || [ "$1" = "rm" ]; then
|
||||
notesSync
|
||||
files=( $notes_dir/*.md )
|
||||
|
||||
|
@ -133,8 +128,8 @@ elif [ "$1" = "remove" ] || [ "$1" = "rm" ]; then
|
|||
done
|
||||
fi
|
||||
|
||||
## ARCHIVE a note from a list
|
||||
elif [ "$1" = "archive" ] || [ "$1" = "a" ]; then
|
||||
## ARCHIVE a note from a list
|
||||
elif [ "$1" = "archive" ] || [ "$1" = "a" ]; then
|
||||
notesSync
|
||||
files=( $notes_dir/*.md )
|
||||
|
||||
|
@ -161,8 +156,8 @@ elif [ "$1" = "archive" ] || [ "$1" = "a" ]; then
|
|||
done
|
||||
fi
|
||||
|
||||
## COPY content a note from a list
|
||||
elif [ "$1" = "copy" ] || [ "$1" = "c" ]; then
|
||||
## COPY content a note from a list
|
||||
elif [ "$1" = "copy" ] || [ "$1" = "c" ]; then
|
||||
files=( $notes_dir/*.md )
|
||||
|
||||
if ! [ "$2" = "" ]; then
|
||||
|
@ -187,7 +182,11 @@ elif [ "$1" = "copy" ] || [ "$1" = "c" ]; then
|
|||
fi
|
||||
|
||||
|
||||
## CREATE a note (default)
|
||||
else
|
||||
## CREATE a note (default)
|
||||
else
|
||||
createNote
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
main
|
Loading…
Reference in a new issue