-
Notifications
You must be signed in to change notification settings - Fork 125
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 --width command line option #70
base: master
Are you sure you want to change the base?
Conversation
@@ -61,6 +64,16 @@ impl Worker { | |||
} | |||
} | |||
|
|||
macro_rules! first_column { |
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.
Macros seem really hacky, but my goal was to just declare the format strings that println!()
uses in one place.
let mut width: usize = 80; | ||
if matches.is_present("width") { | ||
let val = matches.value_of("width"); | ||
let x: Option<&str> = Some("full"); |
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 have enough understanding of Rust's string comparison to compare val
to a string, so I made a throwaway Option to compare to.
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.
He @brewingcode! I'm not the repo person here, but I thought I might help you here. I don't think you need the temporary x
here, you can straight up compare val == Some("full")
.
You might even be able to make something like
let width = match matches.value_of("width") {
Some("full") => return terminal width,
Some(val) => parse the thing,
None => 80,
}
This is so we can start modifying the width of the filename field (at index 0) based on a user-supplied width.
Use the terminal_size crate to use the full terminal width.
As noted in #39, filenames quickly run into truncation issues. This PR allows you to change the output width from the default of 80 chars to another value. Additionally, specifying
full
instead of a number will use theterminal_size
crate to use the whole width of the terminal.