summaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-09-28 21:11:50 +0300
committerPaul Buetow <paul@buetow.org>2021-10-02 12:26:36 +0300
commit609921f9c783941eaa9019a92b78ec45b49d681c (patch)
treec4fc6b20404d0f922dc2825e4624be8c04479cbf /internal/config/config.go
parentfcaa94c7453efa0d74e330128c0f5c2cde8f11b3 (diff)
can have daily and normal file log rotation
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index c9f411c..76dcc65 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -2,6 +2,7 @@ package config
import (
"encoding/json"
+ "flag"
"fmt"
"io/ioutil"
"os"
@@ -78,3 +79,45 @@ func (c *configInitializer) parseSpecificConfig(configFile string) {
panic(fmt.Sprintf("Unable to parse config file %s: %v", configFile, err))
}
}
+
+func (c *configInitializer) transformConfig(args *Args, additionalArgs []string,
+ client *ClientConfig, server *ServerConfig, common *CommonConfig) (*ClientConfig, *ServerConfig, *CommonConfig) {
+ if args.LogDir != "" {
+ common.LogDir = args.LogDir
+ if common.LogStrategy == "" {
+ // TODO: Implement the other (not-daily) log strategy for the server.
+ common.LogStrategy = "daily"
+ }
+ }
+
+ if args.LogLevel != "" {
+ common.LogLevel = args.LogLevel
+ }
+
+ if args.SSHPort != DefaultSSHPort {
+ common.SSHPort = args.SSHPort
+ }
+ if args.NoColor {
+ client.TermColorsEnable = false
+ }
+
+ if args.Spartan {
+ args.Quiet = true
+ args.NoColor = true
+ }
+
+ if args.Discovery == "" && args.ServersStr == "" {
+ args.Serverless = true
+ }
+
+ // Interpret additional args as file list.
+ if args.What == "" {
+ var files []string
+ for _, file := range flag.Args() {
+ files = append(files, file)
+ }
+ args.What = strings.Join(files, ",")
+ }
+
+ return client, server, common
+}