From 869a6fa3849e8ff9891d94f9b4e94eecfd3ad9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Nu=C8=9Biu?= Date: Mon, 1 Jan 2018 16:21:46 +0200 Subject: [PATCH] Adding a new command line flag: config-name --- README.md | 2 ++ server/server/connection.go | 7 +++++-- server/simplFTP.go | 2 ++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6c5986b..f1c518c 100644 --- a/README.md +++ b/README.md @@ -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: 1. address - The address on which to serve diff --git a/server/server/connection.go b/server/server/connection.go index 804a124..1f046af 100644 --- a/server/server/connection.go +++ b/server/server/connection.go @@ -21,9 +21,12 @@ import ( "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 +// 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 var uploadDirectory string @@ -128,7 +131,7 @@ func Init() { clients = make(map[Client]bool) go shutdownHandler() - config.InitializeConfiguration("config", ConfigPath) + config.InitializeConfiguration(ConfigName, ConfigPath) config.ChangeCallback(func(event fsnotify.Event) { log.Println("Configuration reloaded successfully!") }) diff --git a/server/simplFTP.go b/server/simplFTP.go index 0194eac..ac1dd4b 100644 --- a/server/simplFTP.go +++ b/server/simplFTP.go @@ -10,6 +10,8 @@ import ( ) 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.Parse()