Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

brewingcode
Copy link

    -w, --width <N>             Change width of output from 80 to N, or use full terminal width with N = `full`

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 the terminal_size crate to use the whole width of the terminal.

@@ -61,6 +64,16 @@ impl Worker {
}
}

macro_rules! first_column {
Copy link
Author

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");
Copy link
Author

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.

Copy link
Contributor

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants