Fix database not found

This commit is contained in:
andig 2022-12-12 17:00:05 +01:00
parent 3d39375b99
commit d411f4ec38
2 changed files with 2 additions and 2 deletions

View file

@ -57,7 +57,7 @@ func init() {
rootCmd.PersistentFlags().Bool(flagHeaders, false, flagHeadersDescription)
// config file options
rootCmd.PersistentFlags().String(flagSqlite, "", flagSqliteDescription)
rootCmd.PersistentFlags().String(flagSqlite, conf.Database.Dsn, flagSqliteDescription)
bindP(rootCmd, "database.dsn", flagSqlite)
rootCmd.PersistentFlags().StringP("log", "l", "info", "Log level (fatal, error, warn, info, debug, trace)")

View file

@ -81,7 +81,7 @@ func configureEnvironment(cmd *cobra.Command, conf config) (err error) {
// setup persistence
if err == nil && conf.Database.Dsn != "" {
if flag := cmd.Flags().Lookup(flagSqlite); flag.Changed {
if flag := cmd.Flags().Lookup(flagSqlite); flag != nil && flag.Changed {
conf.Database.Type = "sqlite"
conf.Database.Dsn = flag.Value.String()
}