Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upCreated algocfg to provide cli access to config.json #237
Conversation
Adds `algocfg get|set|reset` commands to manipulate config.json in a consistent and typesafe way. Modified config.json is persisted minimally - only non-default values are written. Versioning is taken into account and migration is performed as required. This also includes a fix to SaveNonDefaultValuesToFile() which was writing config.json files with a trailing empty line for each default value that was skipped.
|
||
var dataDirs []string | ||
|
||
func resolveDataDir() string { |
This comment has been minimized.
This comment has been minimized.
algobolson
Aug 14, 2019
Collaborator
these functions exist elsewhere (cmd/goal/... at least) and maybe it's time to extract them? If not libgoal than some other library of algo-command-utils
This comment has been minimized.
This comment has been minimized.
Karmastic
Aug 14, 2019
Author
Contributor
Yes they do. I moved in the direction of extracting them in this PR - moving them to distinct files. I didn't want to incur the extra cost right now.
func setFieldValue(field reflect.Value, value string) error { | ||
switch k := field.Kind(); k { | ||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: | ||
val, err := strconv.ParseInt(value, 10, 64) |
This comment has been minimized.
This comment has been minimized.
algobolson
Aug 14, 2019
Collaborator
we could ParseInt(value, 0, 64), 0-base allows for detecting 0777 octal or 0xabc hex. (Also ParseUint below)
This comment has been minimized.
This comment has been minimized.
Karmastic
Aug 14, 2019
Author
Contributor
We could, but we do not want to or need to. I don't want it to be ambiguous.
looks good. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Karmastic commentedAug 13, 2019
Adds
algocfg get|set|reset
commands to manipulate config.jsonin a consistent and typesafe way.
Modified config.json is persisted minimally - only non-default
values are written. Versioning is taken into account and migration
is performed as required.
This also includes a fix to SaveNonDefaultValuesToFile() which was
writing config.json files with a trailing empty line for each default
value that was skipped.