-
-
Notifications
You must be signed in to change notification settings - Fork 556
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 percent column #258
Add percent column #258
Conversation
src/language/mod.rs
Outdated
|
||
fn add(self, rhs: &Self) -> Self { | ||
let mut stats = self.stats; | ||
stats.extend(rhs.stats.clone()); |
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.
The clone
here is unfortunate, the only way I see around it is for stats to be Vec<Rc<Stat>>
, do you have a better solution?
I decided not to add a test for this because it was basically pointless since percentage is 100% for the individual files. |
src/language/mod.rs
Outdated
@@ -29,6 +30,8 @@ pub struct Language { | |||
pub lines: usize, | |||
/// A collection of statistics based on the files provide from `files` | |||
pub stats: Vec<Stats>, | |||
/// Total percentage of the language in the project | |||
pub percent: usize, |
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.
would you prefer a float?
Thank you for your PR! I'm sorry I should have given more guidance and said what I think the feature should be. As I didn't actually want to add a column. The way I saw this working was behind a flag. I also saw instead of and extra column I saw the output looking like below. Where it showed the absolute and relative values of each compared to the total. For the
|
That is indeed much better. I wasn't comfortable with the way it was implemented anyway. I'll fix |
@BrainMaestro Thank you for working on this, and if you have any questions don't hesitate to ask. |
9bf00c7
to
531cc6d
Compare
See what it looks like
Should the total files be aligned with the files not the percentages? |
@BrainMaestro I think aligned with the number but I'll have to see to confirm. |
531cc6d
to
37c8e4d
Compare
Hi @Aaronepower can you take another look at it? The output is now more inline with what you posted initially.
I tried to reduce the noise a bit. The code isn't so great though |
|
||
let percent_char_count = 5; | ||
// don't show percentage for the total row because that would be pointless | ||
if language.lines == total.lines { |
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.
Instead of passing in total and performing this if statement, why not call total's print_language
with show_percentage
as always false.
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 still need to perform special formatting for total when show_percentage
is true
. It's so that the total number of files line up well. You can see the difference in the last two outputs I posted
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 think then that there should probably be a seperate function for printing total. Currently this implementation changes a lot of behaviour (such as moving the total around which adds additional allocations in AddAssign
) which is not desired.
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.
How would you suggest I do that?
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.
So I've refactored all the printing code into src/cli_utils.rs
so you'll need to move your changes to that. I would suggest having a function called print_total
that handles all the logic of printing out the total.
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'm not able to rework this now, so I'll pick it up again later when I can. I'll just go ahead and close the PR until then. thanks
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.
@BrainMaestro Okay, thank you again for your PR! I'm going to take some time and write a comment on the issue detailing exact requirements so that if and when you do get back to it you'll have a much clearer sense of the task.
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.
@Aaronepower that sounds great.
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'm going to take some time and write a comment on the issue detailing exact requirements
Hi, was this ever written? I'm interested in trying to (re)implement this. Although I'm new to Rust and open source.
Fixes #230