-
Notifications
You must be signed in to change notification settings - Fork 59
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
[Format range] Add --range as a command line option. #299
Conversation
This commit plugs the CLI option to existing range formatting function.
src/erlfmt_cli.erl
Outdated
}. | ||
|
||
resolve_width(undefined, W) -> W; | ||
resolve_width(W, _) -> W. | ||
resolve_undefined(undefined, W) -> W; |
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.
A nit, take it or leave it
But I preferred having verbose functions for each parameter
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.
Argl, it would trigger my DRY obsession!
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.
No problem, but just to explain where my review is coming from.
I prefer readability over DRY.
DRY is only important to me if it removes a large maintenance burden.
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.
Having two functions doing the same thing doesn't match my definition of readability :)
'Same things should share a same name, different things should have distinct names'
Yet, I don't have strong feelings for this one, so I've switched back to one function per parameter.
src/erlfmt.erl
Outdated
@@ -234,7 +262,7 @@ format_file_range(FileName, StartLocation, EndLocation, Options) -> | |||
string(), | |||
erlfmt_scan:location(), | |||
erlfmt_scan:location(), | |||
[{print_width, pos_integer()}] | |||
config() |
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 options verbose
and pragma
are not supported by this function, that is why this is a smaller property list.
Could we change this back?
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, the range was extracted for dispatching purpose, but still sits in this properly list. Would I rather:
- Remove it from the properly list? Con: that's additional work just to
- Introduce a sub_config() type with just
print_width
andrange
? - Other. Con: I have no idea what this alternative is.
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.
We want the function spec to only support what the function actually can support and not say that it can actually influence verbosity or where the output goes.
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.
Done :)
No description provided.