-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Path Command Enhancement Project #2742
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
Conversation
These sounds cool! Thanks! |
Seconded! I like these |
d39c754
to
e369821
Compare
This adds a lot of redundancy to non-relevant subcommands such as type, exists or expand.
`path expand` is still broken but otherwise seems to fix all examples on Windows
Also disable example tests for path expand. Failed caconicalization (e.g., due to path not existing) returns the original path so the examples always fail.
35fed8e
to
039decf
Compare
Wouldn't run on minimal due to useing optional dependency. The test success was also deending on the presence of home dir on the testing machine which might not be completely robust.
Alright, path handling turned out to be a little rabbit hole. The commands mostly respect the I think the path handling would deserve some consistency revamp so it behaves the same way on all platforms but I'll leave it for a further discussion / PR. |
This is great, thanks for putting it together! |
and agreed, we'll want to circle back and improve the path handling a bit more. We can do that in a future PR and land this one, as I think these improvements stand on their own. |
Description
The aim of this PR is to add a couple of options enhancing the capabilities of the
path
subcommands. More specifically, it makes it easier to mass-rename files and their locations without an excessive use ofbuild-string
chains. I found both nu and traditional Unix tools (such as dirname or basename) too verbose when I was encoding and moving tens of thousands images in tens of different folders all over the place.Changes
path basename
--replace <string>
option to replace the basename instead of returning itecho foo/bar/baz.txt | path basename -r spam.md
would returnfoo/bar/spam.md
)path dirname
-n <int>
option to specify how many levels up to returnecho foo/bar/baz.txt | path dirname -n 2
would returnfoo
)--replace <string>
option to replace the dir instead of returning it (respecting the-n
option)echo foo/bar/baz.txt | path dirname -n 2 -r eggs
would returneggs
)path extension
--replace <string>
option to replace the extension instead of returning itecho test.txt | path extension -r md
would returntest.md
)path filestem
--replace <string>
option to replace the filestem instead of returning itecho foo/bar/baz.txt | path basename -r spam
would returnfoo/bar/spam.txt
).tar.gz
out_<whatever>
misc
...args: optionally operate by path
with...args: optionally operate by column path
in subcommands desctiprions