Adding a new command line flag: config-name
This commit is contained in:
parent
7cf561358b
commit
869a6fa384
3 changed files with 9 additions and 2 deletions
|
@ -71,6 +71,8 @@ Sample Configuration File:
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```./simplFT --help``` will list all the command line flags with the associated help text.
|
||||||
|
|
||||||
The **config.json** file contains the following settings:
|
The **config.json** file contains the following settings:
|
||||||
|
|
||||||
1. address - The address on which to serve
|
1. address - The address on which to serve
|
||||||
|
|
|
@ -21,9 +21,12 @@ import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ConfigPath is used by the config package to find the config file.
|
// ConfigPath is used by the config package to find the path of the config file.
|
||||||
var ConfigPath string
|
var ConfigPath string
|
||||||
|
|
||||||
|
// ConfigName is used by the config package to find the config file.
|
||||||
|
var ConfigName string
|
||||||
|
|
||||||
// uploadDirectory is the directory where the files will be uploaded
|
// uploadDirectory is the directory where the files will be uploaded
|
||||||
var uploadDirectory string
|
var uploadDirectory string
|
||||||
|
|
||||||
|
@ -128,7 +131,7 @@ func Init() {
|
||||||
clients = make(map[Client]bool)
|
clients = make(map[Client]bool)
|
||||||
go shutdownHandler()
|
go shutdownHandler()
|
||||||
|
|
||||||
config.InitializeConfiguration("config", ConfigPath)
|
config.InitializeConfiguration(ConfigName, ConfigPath)
|
||||||
config.ChangeCallback(func(event fsnotify.Event) {
|
config.ChangeCallback(func(event fsnotify.Event) {
|
||||||
log.Println("Configuration reloaded successfully!")
|
log.Println("Configuration reloaded successfully!")
|
||||||
})
|
})
|
||||||
|
|
|
@ -10,6 +10,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.StringVar(&server.ConfigName, "config-name", "config",
|
||||||
|
"Set the name of the config file.")
|
||||||
flag.StringVar(&server.ConfigPath, "config", ".", "Set the location of the config file.")
|
flag.StringVar(&server.ConfigPath, "config", ".", "Set the location of the config file.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue