-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli: Add sqlite.Config to general configuration
- Loading branch information
1 parent
65dd32d
commit 8b53aaf
Showing
3 changed files
with
71 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/nicholaspcr/GoDE/cmd/decli/internal/state/sqlite" | ||
"github.com/nicholaspcr/GoDE/internal/log" | ||
) | ||
|
||
// Default configuration of the decli binary. | ||
func Default() *Config { | ||
return &Config{ | ||
Local: LocalConfig{ | ||
PopulationSize: 50, | ||
Generations: 100, | ||
Executions: 1, | ||
Dimensions: Dimensions{ | ||
Size: 7, | ||
Floors: []float64{0, 0, 0, 0, 0, 0, 0}, | ||
Ceils: []float64{1, 1, 1, 1, 1, 1, 1}, | ||
}, | ||
Constants: Constants{ | ||
M: int(3), | ||
CR: float64(0.9), | ||
F: float64(0.5), | ||
P: float64(0.2), | ||
}, | ||
Problem: "dtlz1", | ||
Variant: "rand1", | ||
}, | ||
Log: LogConfig{ | ||
Config: log.DefaultConfig(), | ||
}, | ||
Server: ServerConfig{ | ||
GRPCAddr: "localhost:3030", | ||
HTTPAddr: "http://localhost:8081", | ||
}, | ||
Sqlite: sqlite.Config{ | ||
Provider: "file", | ||
Filepath: ".dev/cli/state.yaml", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
// StringifyJSON returns a string with the JSON object of the configuration. | ||
func (cfg *Config) StringifyJSON() (string, error) { | ||
b, err := json.MarshalIndent(cfg, "", " ") | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(b), nil | ||
} | ||
|
||
// StringifyYAML returns a string block with the yaml configuration contents. | ||
func (cfg *Config) StringifyYAML() (string, error) { | ||
b, err := yaml.Marshal(cfg) | ||
if err != nil { | ||
return "", err | ||
} | ||
return string(b), nil | ||
} |