createApp creates config, initializes app, and returns cleanup function
(fs *flag.FlagSet, dbPath string)
| 113 | |
| 114 | // createApp creates config, initializes app, and returns cleanup function |
| 115 | func createApp(fs *flag.FlagSet, dbPath string) (*app.App, func()) { |
| 116 | cfg, err := config.New(config.Params{ |
| 117 | DBPath: dbPath, |
| 118 | }) |
| 119 | if err != nil { |
| 120 | fmt.Printf("Error: %s\n\n", err) |
| 121 | fs.Usage() |
| 122 | os.Exit(1) |
| 123 | } |
| 124 | |
| 125 | a := initApp(cfg) |
| 126 | cleanup := func() { |
| 127 | sqlDB, err := a.DB.DB() |
| 128 | if err == nil { |
| 129 | sqlDB.Close() |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | return &a, cleanup |
| 134 | } |
no test coverage detected