Replies: 1 comment 1 reply
-
Definitely. Have you tried loading a config file into the argument structure using an external library, then just running arg.MustParse over that? Something like: var args struct {
Test string `arg:"--test" json:"test"`
}
buf, _ := os.ReadFile(configFilePath)
_ = json.Unmarshal(buf, &args)
arg.MustParse(&args) There are several ways that this isn't quite perfect, but I wonder if something like this would work for your use case. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
TL;DR: It would be awesome if it was possible to write and read a configuration
I am writing a CLI with several defaults that fit my case. Others who will (hopefully) use it may have different defaults (this is going to be an open-source CLI so the configurations may be really different).
The solution is to use very long command lines, which is impractical because this is expected to be a CLI one uses often. To fix this, one can create shortcuts in their shell but this is a workaround.
A nice solution would be to read the configuration from a file, and then call
mustParse
to replace arguments that may have been added on the command line. In other words, the fallback would beI understand that this is at the edge of a "command line parser" but with some eye squinting it could fit, no? :)
Beta Was this translation helpful? Give feedback.
All reactions