Unify into single REPL
This commit is contained in:
parent
c45347ec25
commit
7031bc7b07
|
@ -2,23 +2,42 @@ package cli
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"sevenkeys/logic"
|
||||
)
|
||||
|
||||
func MainCliLoop(db *sql.DB) {
|
||||
var command string
|
||||
|
||||
for {
|
||||
ShowSplashScreen()
|
||||
ShowStorageInfo()
|
||||
|
||||
command = GetStringResponse("SEVENKEYS $")
|
||||
|
||||
switch command {
|
||||
case "quit":
|
||||
return
|
||||
case "splash":
|
||||
ShowSplashScreen()
|
||||
case "storage":
|
||||
GetStorageOptions()
|
||||
break
|
||||
case "stash":
|
||||
StashCliLoop(db)
|
||||
case "criteria":
|
||||
getSearchCriteria()
|
||||
break
|
||||
case "search":
|
||||
getSearchOptions(db)
|
||||
var err error
|
||||
selectedCardPrintingId, selectedCardPrintingSearchLine, err = logic.Search(searchOptions)
|
||||
var exitError *exec.ExitError
|
||||
if errors.As(err, &exitError) {
|
||||
break
|
||||
}
|
||||
logic.Check(err)
|
||||
break
|
||||
case "insert":
|
||||
InsertSelectedCard(db)
|
||||
break
|
||||
default:
|
||||
fmt.Println("Unrecognized command:", command)
|
||||
|
|
|
@ -2,9 +2,7 @@ package cli
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"sevenkeys/database"
|
||||
"sevenkeys/logic"
|
||||
)
|
||||
|
@ -94,39 +92,3 @@ func InsertSelectedCard(db *sql.DB) {
|
|||
logic.Check(err)
|
||||
fmt.Println("Inserted card")
|
||||
}
|
||||
|
||||
func StashCliLoop(db *sql.DB) {
|
||||
var command string
|
||||
|
||||
for {
|
||||
ShowStorageInfo()
|
||||
command = GetStringResponse("SEVENKEYS (stash) $")
|
||||
|
||||
switch command {
|
||||
case "back":
|
||||
return
|
||||
case "storage":
|
||||
GetStorageOptions()
|
||||
break
|
||||
case "criteria":
|
||||
getSearchCriteria()
|
||||
break
|
||||
case "search":
|
||||
getSearchOptions(db)
|
||||
var err error
|
||||
selectedCardPrintingId, selectedCardPrintingSearchLine, err = logic.Search(searchOptions)
|
||||
var exitError *exec.ExitError
|
||||
if errors.As(err, &exitError) {
|
||||
break
|
||||
}
|
||||
logic.Check(err)
|
||||
break
|
||||
case "insert":
|
||||
InsertSelectedCard(db)
|
||||
break
|
||||
default:
|
||||
fmt.Println("Unrecognized command:", command)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue