main
|
Last change
on this file since 35bcb41 was b715712, checked in by Stefan <trsunovstefan@…>, 8 weeks ago |
|
Add the server side and configuration
|
-
Property mode
set to
100644
|
|
File size:
761 bytes
|
| Line | |
|---|
| 1 | package main
|
|---|
| 2 |
|
|---|
| 3 | import (
|
|---|
| 4 | "flag"
|
|---|
| 5 | "fmt"
|
|---|
| 6 | "log"
|
|---|
| 7 |
|
|---|
| 8 | "bp_project/server/db"
|
|---|
| 9 | )
|
|---|
| 10 |
|
|---|
| 11 | func main() {
|
|---|
| 12 | initFlag := flag.Bool("init", false, "drop and recreate the project schema, then load sample data")
|
|---|
| 13 | loadData := flag.Bool("load-data", false, "reload sample data (without dropping schema)")
|
|---|
| 14 | flag.Parse()
|
|---|
| 15 |
|
|---|
| 16 | if err := db.Connect(); err != nil {
|
|---|
| 17 | log.Fatalf("database connect failed: %v", err)
|
|---|
| 18 | }
|
|---|
| 19 | defer db.DB.Close()
|
|---|
| 20 |
|
|---|
| 21 | if *initFlag {
|
|---|
| 22 | if err := db.InitSchema(); err != nil {
|
|---|
| 23 | log.Fatalf("init failed: %v", err)
|
|---|
| 24 | }
|
|---|
| 25 | fmt.Println("Schema initialised. Re-run without -init to start the CLI.")
|
|---|
| 26 | return
|
|---|
| 27 | }
|
|---|
| 28 | if *loadData {
|
|---|
| 29 | if err := db.LoadData(); err != nil {
|
|---|
| 30 | log.Fatalf("data load failed: %v", err)
|
|---|
| 31 | }
|
|---|
| 32 | fmt.Println("Sample data reloaded.")
|
|---|
| 33 | return
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | RunCLI()
|
|---|
| 37 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.