From a9cb7156a3b032474dab6f10303a7501e260194b Mon Sep 17 00:00:00 2001 From: SPFab <42518661+SPFabGerman@users.noreply.github.com> Date: Tue, 9 Mar 2021 12:35:50 +0100 Subject: [PATCH] added ability to use custom config file (#587) --- app.go | 14 +++++++++++--- main.go | 6 ++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app.go b/app.go index 69b9f787..97f5f23e 100644 --- a/app.go +++ b/app.go @@ -174,9 +174,17 @@ func (app *app) loop() { }() } - for _, path := range gConfigPaths { - if _, err := os.Stat(path); !os.IsNotExist(err) { - app.readFile(path) + if gCustomConfig != "" { + if _, err := os.Stat(gCustomConfig); !os.IsNotExist(err) { + app.readFile(gCustomConfig) + } else { + log.Printf("Config file does not exist: %s", err) + } + } else { + for _, path := range gConfigPaths { + if _, err := os.Stat(path); !os.IsNotExist(err) { + app.readFile(path) + } } } diff --git a/main.go b/main.go index 5b191002..5820c55f 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ var ( gLogPath string gServerLogPath string gSelect string + gCustomConfig string gCommands arrayFlag gVersion string ) @@ -217,6 +218,11 @@ func main() { "", "path to the file to write selected files on open (to use as open file dialog)") + flag.StringVar(&gCustomConfig, + "config", + "", + "path to a custom config file to be used, instead of normal lfrc file") + flag.Var(&gCommands, "command", "command to execute on client initialization")