file() verification should be able to expand a leading tilde (~)
See original GitHub issuefile()
currently fails for a path like ~/my-file.txt
as ~
is not expanded. It would be great if ~
would be expanded when running on shells that support it similar to like we do here, maybe by introducing an expandTilde
parameter to file()
which defaults to true
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Expand tilde in Rust Path idiomatically - Stack Overflow
The most idiomatic way would be to just use an existing crate, in this case shellexpand (github, crates.io) seems to do what you...
Read more >path.expand: Expand File Paths - Rdrr.io
Expand File Paths. Description. Expand a path name, for example by replacing a leading tilde by the user's home directory (if defined on...
Read more >Tilde expansion if named file exists #3239 - GitHub
I had a mis-configured program that was creating directories named ~ in its working directory. After I fixed the configuration, ...
Read more >bash - How Can I Expand A Tilde ~ As Part Of A Variable?
The shell attempts a tilde expansion on echo $x , there is no tilde to ... This structure explicitly check the presence of...
Read more >Naming Files, Paths, and Namespaces - Win32 apps
This is true even if a long file name contains extended characters, regardless of the code page that is active during a disk...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s correct. I implemented the tilde expansion for file checks in #132, so you can use it with snapshot
2.5.0-beta1.387-SNAPSHOT
or newer if you need the functionality now. Otherwise I’m planning a release within the next week.Sorry about that, I misread your code. The reason it doesn’t work is because
convert
(whichfile
and all conversions call) replaces the existing conversion. So in your case the block passed toconvert
wouldn’t get called, sincefile
overwrites it.The type system normally prevents you from calling convert more than once, since it
convert
usually changes the type of the option. But ifconvert
returns a String, the types stays the same and this mistake is possible to make. Maybe a future version of Clikt will be more strict with they types, but that’s a serious breaking change.