Add storagearea subcommand
This commit is contained in:
parent
f7e0a713f6
commit
c1f581f312
|
@ -2,11 +2,8 @@ package cli
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
|
||||||
"sevenkeys/database"
|
"sevenkeys/database"
|
||||||
"sevenkeys/delverlens"
|
|
||||||
"sevenkeys/logic"
|
"sevenkeys/logic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,8 +44,11 @@ func MainCliLoop(db *sql.DB) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
switch command {
|
switch command {
|
||||||
|
/*
|
||||||
case "q", "quit":
|
case "q", "quit":
|
||||||
return
|
return
|
||||||
|
*/
|
||||||
|
/*
|
||||||
case "n", "newstorage":
|
case "n", "newstorage":
|
||||||
var storageArea database.StorageArea
|
var storageArea database.StorageArea
|
||||||
storageArea.Name = GetStringResponse("Storage area name:")
|
storageArea.Name = GetStringResponse("Storage area name:")
|
||||||
|
@ -56,6 +56,8 @@ func MainCliLoop(db *sql.DB) {
|
||||||
err = logic.CreateStorageArea(db, storageArea)
|
err = logic.CreateStorageArea(db, storageArea)
|
||||||
logic.Check(err)
|
logic.Check(err)
|
||||||
break
|
break
|
||||||
|
*/
|
||||||
|
/*
|
||||||
case "a", "area":
|
case "a", "area":
|
||||||
options, err := logic.GetStorageAreaSearchOptions(db)
|
options, err := logic.GetStorageAreaSearchOptions(db)
|
||||||
logic.Check(err)
|
logic.Check(err)
|
||||||
|
@ -92,11 +94,13 @@ func MainCliLoop(db *sql.DB) {
|
||||||
copiesInserted = 0
|
copiesInserted = 0
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
*/
|
||||||
case "i", "insert":
|
case "i", "insert":
|
||||||
err := logic.StoreCard(db, cardLocation)
|
err := logic.StoreCard(db, cardLocation)
|
||||||
logic.Check(err)
|
logic.Check(err)
|
||||||
copiesInserted++
|
copiesInserted++
|
||||||
break
|
break
|
||||||
|
/*
|
||||||
case "d", "delverlens":
|
case "d", "delverlens":
|
||||||
filename := GetStringResponse("Filename:")
|
filename := GetStringResponse("Filename:")
|
||||||
|
|
||||||
|
@ -106,6 +110,8 @@ func MainCliLoop(db *sql.DB) {
|
||||||
err = logic.ImportDelverLensCards(db, cards, cardLocation.StorageAreaId)
|
err = logic.ImportDelverLensCards(db, cards, cardLocation.StorageAreaId)
|
||||||
logic.Check(err)
|
logic.Check(err)
|
||||||
break
|
break
|
||||||
|
*/
|
||||||
|
/*
|
||||||
case "l", "locate":
|
case "l", "locate":
|
||||||
filename := GetStringResponse("Filename:")
|
filename := GetStringResponse("Filename:")
|
||||||
cardNames, err := logic.GetCardNamesFromFile(filename)
|
cardNames, err := logic.GetCardNamesFromFile(filename)
|
||||||
|
@ -141,6 +147,7 @@ func MainCliLoop(db *sql.DB) {
|
||||||
fmt.Println("Though this query has ended, its relics still slumber in New Argive.")
|
fmt.Println("Though this query has ended, its relics still slumber in New Argive.")
|
||||||
fmt.Scanln()
|
fmt.Scanln()
|
||||||
break
|
break
|
||||||
|
*/
|
||||||
default:
|
default:
|
||||||
fmt.Println("Unrecognized command:", command)
|
fmt.Println("Unrecognized command:", command)
|
||||||
break
|
break
|
||||||
|
|
|
@ -7,12 +7,12 @@ import (
|
||||||
"sevenkeys/cli"
|
"sevenkeys/cli"
|
||||||
"sevenkeys/database"
|
"sevenkeys/database"
|
||||||
"sevenkeys/delverlens"
|
"sevenkeys/delverlens"
|
||||||
"sevenkeys/figlet"
|
|
||||||
"sevenkeys/logic"
|
"sevenkeys/logic"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
UpdateSubcommand string = "update"
|
UpdateSubcommand string = "update"
|
||||||
|
CreateStorageAreaSubcommand string = "createstorage"
|
||||||
ImportSubcommand string = "import"
|
ImportSubcommand string = "import"
|
||||||
SearchSubcommand string = "search"
|
SearchSubcommand string = "search"
|
||||||
)
|
)
|
||||||
|
@ -24,15 +24,14 @@ func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
db := database.GetDatabaseFromConfig("config." + profile + ".json")
|
db := database.GetDatabaseFromConfig("config." + profile + ".json")
|
||||||
|
/* Sad.
|
||||||
figlet.ReadFigletFonts()
|
figlet.ReadFigletFonts()
|
||||||
cli.ShowSplashScreen()
|
cli.ShowSplashScreen()
|
||||||
|
*/
|
||||||
|
|
||||||
// TODO: Decide in what form we need to retain this functionality if any
|
// TODO: Decide in what form we need to retain this functionality if any
|
||||||
//cli.MainCliLoop(db)
|
//cli.MainCliLoop(db)
|
||||||
|
|
||||||
importCmd := flag.NewFlagSet(ImportSubcommand, flag.ExitOnError)
|
|
||||||
storageArea := importCmd.String("storagearea", "", "The name of the StorageArea where cards should be imported.")
|
|
||||||
|
|
||||||
//searchCmd := flag.NewFlagSet(SearchSubcommand, flag.ExitOnError)
|
//searchCmd := flag.NewFlagSet(SearchSubcommand, flag.ExitOnError)
|
||||||
//name := searchCmd.String("name", "", "The card name to search for.")
|
//name := searchCmd.String("name", "", "The card name to search for.")
|
||||||
|
|
||||||
|
@ -44,8 +43,26 @@ func main() {
|
||||||
switch flag.Args()[0] {
|
switch flag.Args()[0] {
|
||||||
case UpdateSubcommand:
|
case UpdateSubcommand:
|
||||||
cli.RunUpdateCheck(db)
|
cli.RunUpdateCheck(db)
|
||||||
|
break
|
||||||
|
case CreateStorageAreaSubcommand:
|
||||||
|
createStorageCmd := flag.NewFlagSet(CreateStorageAreaSubcommand, flag.ExitOnError)
|
||||||
|
storageAreaName := createStorageCmd.String("name", "",
|
||||||
|
"The name of the StorageArea to create.")
|
||||||
|
storageAreaType := createStorageCmd.String("type", "",
|
||||||
|
"The name of the StorageArea to create.")
|
||||||
|
|
||||||
|
createStorageCmd.Parse(flag.Args()[1:])
|
||||||
|
|
||||||
|
storageArea := database.StorageArea{Name: *storageAreaName, StorageType: *storageAreaType}
|
||||||
|
err := logic.CreateStorageArea(db, storageArea)
|
||||||
|
logic.Check(err)
|
||||||
|
|
||||||
break
|
break
|
||||||
case ImportSubcommand:
|
case ImportSubcommand:
|
||||||
|
importCmd := flag.NewFlagSet(ImportSubcommand, flag.ExitOnError)
|
||||||
|
storageArea := importCmd.String("storagearea", "",
|
||||||
|
"The name of the StorageArea where cards should be imported.")
|
||||||
|
|
||||||
importCmd.Parse(flag.Args()[1:])
|
importCmd.Parse(flag.Args()[1:])
|
||||||
|
|
||||||
storageAreaId, err := logic.GetStorageAreaId(db, *storageArea)
|
storageAreaId, err := logic.GetStorageAreaId(db, *storageArea)
|
||||||
|
|
Loading…
Reference in New Issue