diff options
| author | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2026-07-20 16:14:29 +0530 |
|---|---|---|
| committer | Vidhu Kant Sharma <vidhukant@vidhukant.com> | 2026-07-20 16:14:29 +0530 |
| commit | 7ddcfd4d6421473dca5e19b9f8aa227a52382ee3 (patch) | |
| tree | e70781dd6344a93e2a5378ed13c00f980f296f1c /cmd/root.go | |
| parent | 3a089525cbc8a5b0ba86878e3fe5deec663a0f81 (diff) | |
added 'default guestbook' optionv1.7.0
Diffstat (limited to 'cmd/root.go')
| -rw-r--r-- | cmd/root.go | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/cmd/root.go b/cmd/root.go index 0a7d0e6..b3b8395 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -27,11 +27,13 @@ import ( var rootCmd = &cobra.Command{ Use: "guestbook", - Version: "v1.6.2", + Version: "v1.7.0", Short: "Standalone guestbook server for static websites", Long: "Standalone guestbook server for static websites", } +var defaultGuestbook string = "my_guestbook" + func Execute() { err := rootCmd.Execute() if err != nil { @@ -40,12 +42,14 @@ func Execute() { } func init() { - cobra.OnInitialize(func () { - viper.SetConfigName("guestbook") - viper.AddConfigPath("/etc") - - if err := viper.ReadInConfig(); err != nil { - log.Fatal(err) - } - }) + viper.SetConfigName("guestbook") + viper.AddConfigPath("/etc") + + if err := viper.ReadInConfig(); err != nil { + log.Fatal(err) + } + + if viper.IsSet("default_guestbook") { + defaultGuestbook = viper.GetString("default_guestbook") + } } |