templatize the starter deck

This commit is contained in:
Bryan Jenks 2020-04-18 16:39:13 -07:00
parent 7d7a97bbce
commit 3b49bbb99a
1 changed files with 9 additions and 6 deletions

15
flash
View File

@ -22,20 +22,23 @@
# fzf - https://github.com/junegunn/fzf # fzf - https://github.com/junegunn/fzf
# bat - https://github.com/sharkdp/bat # bat - https://github.com/sharkdp/bat
#==============================================================# #==============================================================#
PWD="$(pwd)" # Remember User's Starting Directory
DIR="$HOME/.local/share/flash" # Where Decks Are Located
EXAMPLE_DECK="$HOME/.local/share/flash/deck.csv"
COUNTER=0
DIR_MADE_MSG=" DIR_MADE_MSG="
Your '~/.local/share/flash' directory has been made and Your '~/.local/share/flash' directory has been made and
your 'deck.csv' file is ready for you to enter your flashcard data your 'deck.csv' file is ready for you to enter your flashcard data
" "
PWD="$(pwd)" # Remember User's Starting Directory
DIR="$HOME/.local/share/flash" # Where Decks Are Located
COUNTER=0
NO_DECKS=" NO_DECKS="
No decks were found, please make a new deck No decks were found, please make a new deck
using ':' as a delimiter in a '.csv' file in using ':' as a delimiter in a '.csv' file in
the '.local/share/flash' directory. the '.local/share/flash' directory.
" "
TEMPLATE_DECK="$HOME/.local/share/flash/deck.csv" DECK_TEMPLATE="category1:question1:answer1
category2:question2:answer2
category3:question3:answer3
"
if [ ! -d $DIR ];then # If Directory does NOT exist if [ ! -d $DIR ];then # If Directory does NOT exist
echo "No '.local/share/flash' directory, make it? y/n" echo "No '.local/share/flash' directory, make it? y/n"
@ -43,7 +46,7 @@ if [ ! -d $DIR ];then # If Directory does NOT exist
case "$RESPONSE" in case "$RESPONSE" in
[Nn]) exit ;; [Nn]) exit ;;
[Qq]) exit ;; [Qq]) exit ;;
[Yy]) mkdir $DIR && touch $TEMPLATE_DECK && echo "category1:question1:answer1" >> $TEMPLATE_DECK && echo "category2:question2:answer2" >> $TEMPLATE_DECK && echo "category3:question3:answer3" >> $TEMPLATE_DECK && echo "$DIR_MADE_MSG" ;; [Yy]) mkdir "$DIR" && touch $EXAMPLE_DECK && echo "$DECK_TEMPLATE" >> $EXAMPLE_DECK && echo "$DIR_MADE_MSG" ;;
*) echo "invalid choice, please select either 'y' or 'n'" ;; *) echo "invalid choice, please select either 'y' or 'n'" ;;
esac esac
fi fi