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
Consider reworking arguments to file() #114
Comments
I agree that that parameter names can be improved, and I like your suggestions. Changing parameter names is a breaking change, and, unlike with functions, there's no way to deprecate a parameter. So in this case, I'd prefer backwards compatibility over clarity. |
True. I had briefly thought about how to remedy that, and my idea was to simply double all parameters during some transition period. That is, the function signature would be
When using named parameters you could choose to only user the new names. However, that's still not exactly nice by itself, and you would have to do some internal alignment of old and new parameters. Another option would be to simply introduce a new function, like So in the end I'm completely fine with you closing this issue as-is, or maybe keeping it around until it's time for a breaking change, like for a new major version of clikt. |
Thinking about it more, we could maintain backward compatibility and use |
That's a neat trick. How about a new parameter |
Yeah, that's perfect. |
FYI, I recently discovered a neat trick to identify symlinks that also works on Windows. |
Thanks! Neither that method or |
There are actually two kinds of native "symlinks" on Windows: Junctions (for directories only; since Windows 2000) and "real" symbolic links (since Windows Vista). Both of these should be detected by my code snippet. The best tool I know to create / handle these on Windows is the Link Shell Extension. |
Cygwin, on the other hand, by default uses its own home-brewn file format to simulate symlinks. That feature dates back to when Windows did not have any kind of native symlinks, i.e. it's ancient. I do not think it's worth the effort to support these at all, esp. as nowadays Cygwin can be told to create native symlinks instead. |
So in the end it seems that this trick doesn't quite work. It works perfectly for calls like |
Hmm, thanks for giving this a try anyway. So either we simply discard the whole issue, or we accept that something like |
I decided on a solution that isn't perfect, but that I'm okay with: I added the Calls with unnamed arguments (e.g. |
Thanks for this! |
I'm always having trouble remembering what checks exactly are performed for the different parameters to
file()
. For example, doesexists = false
check whether the file does not exist and fail otherwise? (No, it does not.) While that's part of the documentation, I believe this could be made more clear by renaming parameters. How about:exists
->verifyExists
fileOkay
->canBeFile
folderOkay
->canBeDir
writable
->mustBeWritable
readable
->mustBeReadable
The text was updated successfully, but these errors were encountered: