Add config file, handle it with Viper, add a command to open it in an editor
This commit is contained in:
parent
b8a8ba2e08
commit
61aa5880d3
234 changed files with 44636 additions and 383 deletions
|
@ -2,6 +2,7 @@ package commands
|
|||
|
||||
import (
|
||||
"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/spf13/cobra"
|
||||
"github.com/khlieng/name_pending/Godeps/_workspace/src/github.com/spf13/viper"
|
||||
|
||||
"github.com/khlieng/name_pending/server"
|
||||
"github.com/khlieng/name_pending/storage"
|
||||
|
@ -13,17 +14,22 @@ var (
|
|||
Short: "Web-based IRC client in Go.",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
storage.Initialize()
|
||||
server.Run(port)
|
||||
server.Run(viper.GetInt("port"))
|
||||
},
|
||||
}
|
||||
|
||||
port int
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(clearCmd)
|
||||
rootCmd.AddCommand(configCmd)
|
||||
|
||||
rootCmd.Flags().IntVarP(&port, "port", "p", 1337, "port to listen on")
|
||||
rootCmd.Flags().IntP("port", "p", 1337, "port to listen on")
|
||||
|
||||
viper.SetConfigName("config")
|
||||
viper.AddConfigPath(storage.AppDir)
|
||||
viper.ReadInConfig()
|
||||
|
||||
viper.BindPFlag("port", rootCmd.Flags().Lookup("port"))
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue