TheMathemagicians/sevenkeys/main.go

48 lines
1.0 KiB
Go

package main
import (
"flag"
"fmt"
"os"
"sevenkeys/cli"
"sevenkeys/database"
"sevenkeys/figlet"
)
const (
ImportSubcommand string = "import"
)
func main() {
profile := os.Getenv("SEVENKEYS_PROFILE")
db := database.GetDatabaseFromConfig("config." + profile + ".json")
figlet.ReadFigletFonts()
cli.ShowSplashScreen()
cli.RunUpdateCheck(db)
// TODO: Decide in what form we need to retain this functionality if any
//cli.MainCliLoop(db)
importCmd := flag.NewFlagSet("import", flag.ExitOnError)
storageArea := importCmd.String("storagearea", "", "The name of the StorageArea where cards should be imported.")
if len(os.Args) < 2 {
fmt.Fprintln(os.Stderr, "Please specify a subcommand.")
os.Exit(1)
}
switch os.Args[1] {
case ImportSubcommand:
// TODO: Get filename, run import code
importCmd.Parse(os.Args[2:])
//storageAreaId := logic.GetStorageAreaIdByName(db, *storageArea)
fmt.Printf("Filename: %s\n", importCmd.Args()[0])
break
default:
fmt.Fprintf(os.Stderr, "Unrecognized subcommand: %s\n", os.Args[1])
break
}
}