Write basic loop for inserter program
This commit is contained in:
parent
3cee8b7b9b
commit
2fd868ee9c
|
@ -1,5 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
printLastInsertedCard() {
|
||||
printf "Last inserted card: "
|
||||
|
||||
if test -n "$1"; then
|
||||
printf "$1"
|
||||
else
|
||||
printf "None"
|
||||
fi
|
||||
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
searchForCard() {
|
||||
# TODO: Add keybinding to show card image with feh
|
||||
./printinglist | fzf
|
||||
}
|
||||
|
||||
declare g_lastInsertedCardId
|
||||
declare g_lastInsertedCardName
|
||||
|
||||
while true; do
|
||||
printf "Hello, world\n"
|
||||
clear
|
||||
|
||||
printLastInsertedCard "$g_lastInsertedCardName"
|
||||
|
||||
printf "search? (y/N)"
|
||||
read response
|
||||
if [[ "$response" == "y" ]]; then
|
||||
selection="$(searchForCard)"
|
||||
case "$?" in
|
||||
0)
|
||||
# Insert the card
|
||||
printf "$selection\n"
|
||||
# TODO: set last inserted card name and id
|
||||
;;
|
||||
1)
|
||||
# Print "no match" error
|
||||
;;
|
||||
2)
|
||||
# Print error
|
||||
;;
|
||||
130)
|
||||
# User cancelled search
|
||||
;;
|
||||
esac
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue