diff --git a/sevenkeys/main.go b/sevenkeys/main.go index a4e3310..3830fed 100644 --- a/sevenkeys/main.go +++ b/sevenkeys/main.go @@ -9,36 +9,39 @@ import ( "sevenkeys/figlet" ) -type ModeOfOperation string - const ( - ModeImport ModeOfOperation = "import" - ModeInteractive = "interactive" + ImportSubcommand string = "import" ) func main() { - var profile string - flag.StringVar(&profile, "profile", "production", "the database profile to use") - - modePtr := flag.String("mode", "interactive", "the mode of operation") - - flag.Parse() - mode := ModeOfOperation(*modePtr) + profile := os.Getenv("SEVENKEYS_PROFILE") db := database.GetDatabaseFromConfig("config." + profile + ".json") figlet.ReadFigletFonts() cli.ShowSplashScreen() cli.RunUpdateCheck(db) - switch mode { - case ModeImport: + // 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 - break - case ModeInteractive: - cli.MainCliLoop(db) + 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 mode: %s\n", mode) + fmt.Fprintf(os.Stderr, "Unrecognized subcommand: %s\n", os.Args[1]) break } }