2020-11-30 09:37:17 +00:00
|
|
|
package csconfig
|
|
|
|
|
2022-10-07 09:05:35 +00:00
|
|
|
import (
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
2020-11-30 09:37:17 +00:00
|
|
|
/*cscli specific config, such as hub directory*/
|
|
|
|
type CscliCfg struct {
|
|
|
|
Output string `yaml:"output,omitempty"`
|
2022-10-07 09:05:35 +00:00
|
|
|
Color string `yaml:"color,omitempty"`
|
2020-11-30 09:37:17 +00:00
|
|
|
HubBranch string `yaml:"hub_branch"`
|
|
|
|
SimulationConfig *SimulationConfig `yaml:"-"`
|
|
|
|
DbConfig *DatabaseCfg `yaml:"-"`
|
|
|
|
HubDir string `yaml:"-"`
|
|
|
|
DataDir string `yaml:"-"`
|
|
|
|
ConfigDir string `yaml:"-"`
|
|
|
|
HubIndexFile string `yaml:"-"`
|
|
|
|
SimulationFilePath string `yaml:"-"`
|
2021-02-17 12:53:57 +00:00
|
|
|
PrometheusUrl string `yaml:"prometheus_uri"`
|
2020-11-30 09:37:17 +00:00
|
|
|
}
|
2021-03-24 17:16:17 +00:00
|
|
|
|
2022-10-07 09:05:35 +00:00
|
|
|
func ColorDefault() string {
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
return "no"
|
|
|
|
}
|
|
|
|
return "auto"
|
|
|
|
}
|
|
|
|
|
2021-03-24 17:16:17 +00:00
|
|
|
func (c *Config) LoadCSCLI() error {
|
|
|
|
if c.Cscli == nil {
|
|
|
|
c.Cscli = &CscliCfg{}
|
|
|
|
}
|
|
|
|
if err := c.LoadConfigurationPaths(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
c.Cscli.ConfigDir = c.ConfigPaths.ConfigDir
|
|
|
|
c.Cscli.DataDir = c.ConfigPaths.DataDir
|
|
|
|
c.Cscli.HubDir = c.ConfigPaths.HubDir
|
|
|
|
c.Cscli.HubIndexFile = c.ConfigPaths.HubIndexFile
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|