Update storage UI
This commit is contained in:
parent
8fe02f46d6
commit
de116aee20
|
@ -4,6 +4,7 @@ import (
|
|||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"sevenkeys/database"
|
||||
"sevenkeys/logic"
|
||||
|
@ -19,10 +20,11 @@ func showOutput() {
|
|||
|
||||
func MainCliLoop(db *sql.DB) {
|
||||
var command string
|
||||
var selectedStorageArea database.StorageArea
|
||||
|
||||
for {
|
||||
ShowSplashScreen()
|
||||
showStorageInfo()
|
||||
showStorageInfo(os.Stdout, selectedStorageArea)
|
||||
showSearchCriteria()
|
||||
showSelectedCard()
|
||||
showCopiesInserted()
|
||||
|
|
|
@ -3,6 +3,7 @@ package cli
|
|||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"io"
|
||||
"sevenkeys/database"
|
||||
"sevenkeys/logic"
|
||||
)
|
||||
|
@ -22,18 +23,15 @@ func getInfoDisplay(info string) string {
|
|||
return info
|
||||
}
|
||||
|
||||
func showStorageInfo() {
|
||||
fmt.Println("STORAGE SETTINGS")
|
||||
func showStorageInfo(w io.Writer, area database.StorageArea) {
|
||||
fmt.Fprint(w, "Selected Storage Area: ")
|
||||
if area.Name == "" {
|
||||
fmt.Fprint(w, "[None]\n")
|
||||
return
|
||||
}
|
||||
|
||||
storageBoxDisplay := getInfoDisplay(cardStorageLocation.StorageBox)
|
||||
sourceDisplay := getInfoDisplay(cardStorageLocation.Source)
|
||||
conditionDisplay := getInfoDisplay(cardStorageLocation.CardCondition)
|
||||
|
||||
fmt.Println("Storage location:", storageBoxDisplay)
|
||||
fmt.Println("Source:", sourceDisplay)
|
||||
fmt.Println("Condition:", conditionDisplay)
|
||||
|
||||
fmt.Print("\n")
|
||||
fmt.Fprintf(w, "%s (%s)\n", area.Name, area.Type)
|
||||
return
|
||||
}
|
||||
|
||||
func showCopiesInserted() {
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"sevenkeys/database"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func Test_showStorageInfo_DisplaysNone_IfSelectedStorageAreaIsUnset(t *testing.T) {
|
||||
expected := "Selected Storage Area: [None]\n"
|
||||
|
||||
var output bytes.Buffer
|
||||
|
||||
var area database.StorageArea
|
||||
showStorageInfo(&output, area)
|
||||
|
||||
result := output.String()
|
||||
if result != expected {
|
||||
t.Errorf("expected %s, got %s", expected, result)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_showStorageInfo_DisplaysStorageAreaNameAndType_IfSelectedStorageAreaIsSet(t *testing.T) {
|
||||
expected := "Selected Storage Area: Test A (Box)\n"
|
||||
|
||||
var output bytes.Buffer
|
||||
|
||||
area := database.StorageArea{
|
||||
Id: 1,
|
||||
Name: "Test A",
|
||||
Type: "Box",
|
||||
}
|
||||
showStorageInfo(&output, area)
|
||||
|
||||
result := output.String()
|
||||
if result != expected {
|
||||
t.Errorf("expected %s, got %s", expected, result)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue