-
Notifications
You must be signed in to change notification settings - Fork 20
Restructuring #13
Restructuring #13
Conversation
alrighty @dantuck - this is ready to go now. Since it has been a while since I have published a version of this to crates.io, I'll do that after this gets merged. |
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.
This looks really good. Nice work! I made a suggestion on the error result if you would like to take it. Other than that this looks like a good restructure.
As a follow up maybe we can chat about cleaning up the error output a little so that it doesn't look so programmer like:
➜ rust_ledger git:(fs) RLEDGER_FILE=examples/example.yal cargo run register
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/rust_ledger register`
Error: IOError(Os { code: 2, kind: NotFound, message: "No such file or directory" })
would become:
➜ rust_ledger git:(fs) RLEDGER_FILE=examples/example.yal cargo run register
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
Running `target/debug/rust_ledger register`
No such file or directory
Or something similar. I have been making some implementation changes to error output in another project that you could probably implement here.
|
||
// define expected args for pargs | ||
let command_args: Vec<String> = vec![ | ||
String::from("account"), |
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 like this change going to singular. Clean and consistent with the other commands.
use std::io; | ||
|
||
extern crate csv; | ||
|
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.
You could add:
/// A type alias for `Result<T, Error>`.
pub type Result<T> = result::Result<T, Error>;
Which would allow you to change:
pub fn register(filename: &String, option: &String) -> Result<(), Error>
to
pub fn register(filename: &String, option: &String) -> Result
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.
This a nice shortcut - thanks!
fn main() -> Result<(), error::Error> { | ||
cli::run() |
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.
And now that is CLEAN!
Great - please do let me know what you find. I spent some time trying to figure out how to parse the default I'll merge this in the meantime. Appreciate the quick review! |
stdout
output but this is a good starting place. Besides, the previous tests did not add a lot of value, either.