fix: adapts db initialization in root command
This commit is contained in:
parent
9ee6876e95
commit
1c4a83981e
1 changed files with 5 additions and 2 deletions
|
|
@ -52,6 +52,9 @@ Where f[r]eed is different to other feed aggregators or bookmarking services is
|
||||||
|
|
||||||
The application also includes a set of recommended "Small Web" and topic-specific curated feeds. These are also available through the configuration.
|
The application also includes a set of recommended "Small Web" and topic-specific curated feeds. These are also available through the configuration.
|
||||||
`,
|
`,
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
initDB()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -64,7 +67,7 @@ func Execute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
cobra.OnInitialize(initConfig, initDB)
|
cobra.OnInitialize(initConfig)
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: ~/.config/freed/config.toml)")
|
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default: ~/.config/freed/config.toml)")
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +96,7 @@ func initConfig() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
viper.SetDefault("database.path", "freed.sqlite3")
|
viper.SetDefault("database.path", "freed.db")
|
||||||
|
|
||||||
if err := viper.Unmarshal(&appContext.Config); err != nil {
|
if err := viper.Unmarshal(&appContext.Config); err != nil {
|
||||||
fmt.Printf("Could not read config file: %s", err)
|
fmt.Printf("Could not read config file: %s", err)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue