-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an expandconfig
utility to add default values
#178
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just minor style comments/questions.
src/bin/expandconfig.rs
Outdated
let args: Vec<String> = env::args().collect(); | ||
let program = args[0].clone(); | ||
|
||
let mut opts = Options::new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is their a reason why you didn't use structopt
as you did in treesize ? I found structop
much nicer to write/read.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree :)
What happened here is that I initially just read from stdin / wrote to stdout without args, then reached for getopts
to make it a bit nicer since it was already a dependency of telamon
. I didn't want to add structopt
/clap
dependencies, which are somewhat heavy, just for such a simple utility with two options. That may be misguided, esp. if we want to use structopt
/clap
for other CLI utilities in the future; I'm fine with converting the code if you prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I would prefer we use a single library for all CLI tools. And structopt/clap seems the nicest way to go.
This patch adds an `expandconfig` binary which is able to load a configuration file, and write it back (in either TOML or YAML format) with the default values expanded. This is useful in a variety of scenarios: - Check that a configuration file is valid with: expandconfig /path/to/config.toml - See default field values and structure with: expandconfig - See all available fields with (YAML displays fields with a default `None` value while TOML skips them): expandconfig -f yaml
528a1fa
to
8181ac2
Compare
@ulysseB |
Ok. Can I merge this ? |
src/bin/expandconfig.rs
Outdated
|
||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
struct ParseFormatError { | ||
_priv: (), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this field ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't need it; it's just to prevent creating the error from somewhere else, which is not actually very useful. I can remove it.
bors r=ulysseB |
178: Add an `expandconfig` utility to add default values r=ulysseB a=Elarnon This patch adds an `expandconfig` binary which is able to load a configuration file, and write it back (in either TOML or YAML format) with the default values expanded. This is useful in a variety of scenarios: - Check that a configuration file is valid with: expandconfig /path/to/config.toml - See default field values and structure with: expandconfig - See all available fields with (YAML displays fields with a default `None` value while TOML skips them): expandconfig -f yaml Co-authored-by: Basile Clement <basile@clement.pm> Co-authored-by: Basile Clement <basile.clement@ens.fr> Co-authored-by: Basile Clement <elarnon@users.noreply.github.com>
Build succeeded |
This patch adds an
expandconfig
binary which is able to load aconfiguration file, and write it back (in either TOML or YAML format)
with the default values expanded. This is useful in a variety of
scenarios:
Check that a configuration file is valid with:
expandconfig /path/to/config.toml
See default field values and structure with:
expandconfig
See all available fields with (YAML displays fields with a default
None
value while TOML skips them):expandconfig -f yaml