-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Save Results #43
base: main
Are you sure you want to change the base?
Save Results #43
Conversation
This removes std::time in favor of chrono because chrono has built-in support for serde via the "serde" features flag.
Thank you for this @treatybreaker. I haven't been able to find time to review this PR thoroughly, it will take some more time. Some thoughts though:
|
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.
Your code looks pretty good! Just one suggestion for now. I haven't looked too closely and I haven't tried it out yet, so I may have some more comments later.
if config.results_file.is_none() { | ||
config.results_file = match std::env::var("TOIPE_RESULTS_FILE") { | ||
Ok(results_file_env) => Some(results_file_env), | ||
Err(_) => None, | ||
} | ||
} | ||
|
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.
clap
supports reading a configuration value from an environment variable. See env
under https://docs.rs/clap/latest/clap/_derive/index.html#arg-attributes. Could you add that to the ToipeConfig
struct and remove this code from here?
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 can take a look and get those changes in. I'm pretty busy myself as it stands, so I likely won't be able to get around to it until this coming weekend. Only saw this now due to my inbox refreshing.
This PR closes issue #11.
Summary
This PR adds the ability to save results to a file via the
-r
flag. In the current implementation results are not saved by default, instead the user must pass either the new-r
flag and a path or set theTOIPE_RESULTS_FILE
environment variable to a file path.Notes
The only thing that we might want to modify is the error type being returned by the
save_results
function I've added. I do not useToipeError
and instead fall back onstd::io::Error
which gets unrolled up where it is then turned intoToipeError
, but in doing so the error information is dropped. See here for thesave_results
function and here for how I'm taking the error in and returningToipeError
.Let me know what suggestions you have and I'll be happy to make any relevant modifications. I'm not the biggest Rust guy, so I may have missed more idiomatic patterns that would improve this PR.