-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added -S flag for truncating long lines #2309
Conversation
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.
Thanks! Please also add one or two basic regression tests for this change. And also add an entry to CHANGELOG.md please.
338d915
to
c1b6fe9
Compare
I added some tests and added the change to the |
c978423
to
26acd63
Compare
26acd63
to
236a2c5
Compare
Oops it looks like I had reversed logic and set
I added some tests that cover historical functionality not implemented by this PR because those cases were not yet covered and I wanted to make sure that my changes didn't alter existing functionality. |
tests/examples/80-columns.txt
Outdated
@@ -0,0 +1 @@ | |||
abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz |
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.
Shouldn't this file be called 100-columns.txt
? Another proposal: long-single-line.txt
.
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.
Oh, I like long-single-line.txt
, I'll go with 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.
Looks good! Just a couple of nit-picks.
tests/integration_tests.rs
Outdated
let expected = | ||
"abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n"; | ||
|
||
bat() |
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.
There is a substantial amount of copy-paste here. Would be nice to introduce a helper function that takes as parameter the only thing that varies among the tests (expected output and the wrapping arg).
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.
Added a helper function.
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 added the helper function in the tests/integration_tests.rs
file, but is this the correct procedure? I don't see any other helper functions in this file, so I figured I should ask.
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.
Yep it was correct to put the helper next to the functions that need it
I don't expect any other code to ever need that helper, so it makes sense to put it where you put it
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 test code looks much better now, thanks! I found one more comment to make
Co-authored-by: Martin Nordholts <enselic@gmail.com>
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.
Looks mergeable to me, thanks!
Thank you very much |
Implementation of feature mentioned in issue #2239. Added both
--chop-long-lines
and-S
as flags.