simulatino / trimtrailingwhitespaces

Python script that detects textfiles and then removes trailing white spaces and more.
The Unlicense
11 stars 2 forks source link

Add argument option to force a certain EOL style #9

Closed dietmarw closed 10 years ago

dietmarw commented 10 years ago

Some users (see also #6) would like to force a non-native EOL style for their files. There should be an argument option for this. I suggest to call it --eol-style and it should accept the values LF or CRLF. Not sure if CR is of interest to Mac users (@dietmarw looks at the new Mac fanboy @fnd).

dietmarw commented 10 years ago

I implemented it with the name --eol=[CRLF|LF|CR]. Pull-request for review by @tbeu coming up.

tbeu commented 10 years ago

What is the default value of the --eol argument? I recommend to add default option (e.g. if --eol is not defined) and keep EOL sytle as it is.

dietmarw commented 10 years ago

The default is what ever the system deafult is. So Windows will be CRLF and POSIX LF. Also documented in https://github.com/dietmarw/trimtrailingwhitespaces/commit/d19c1c9fe832a0b8b9933494a60fae30a153e0f2#diff-b6ad2639d902e118b85eee99b74a4e63R111

tbeu commented 10 years ago

Wish: Would be nice to have beside CRLF, LF and CR the new EOL style options OS (for OS default) and KEEP (for do not change).

dietmarw commented 10 years ago

OS is superfluous since it is the default when nothing is specified. I don't see a practical reason for KEEP. Either you want to clean up trailing whitespaces and line-endings or you don't. Removing white spaces but leaving mixed line-endings just makes no sense to me. Maybe you can give an real-life example where this would be sensible (and I don't take bad coding practices as an excuse ;-))

tbeu commented 10 years ago

The reason is pretty simple. I have two files where one is with CRLF and another with CF. And of course I do not want to inspect each file before running trimWhitespace individually on it. I simply want to remobe trailing white space and do not touch the EOL style.

dietmarw commented 10 years ago

May I ask what the reason is for having two different line endings in files of the same project?

tbeu commented 10 years ago

Do not care about the reason. Say it is a test library for line endings if you want.

dietmarw commented 10 years ago

Well in that case I don't see a reason to fix it for just the sake of tests. The tool is meant to help keeping clean codes. Mixed-style line endings within a project is out of the focus here. I'm going to update my pull request with some PEP8 cleanups.