-
Notifications
You must be signed in to change notification settings - Fork 242
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
add path replace-extension
to stdlib-candidate
#1002
Conversation
This reverts commit 43d1224.
I think we need tests for stdlib candidates please. |
@fdncred As part of the updated
We can revise that if need be. My thoughts on this were that not everything we put in |
I think it's a mistake to not require tests for candidates. |
OK, I think it's good to add tests for candidates. |
Thanks for all the changes. I personally think it's good to have these test mechanisms in here. I think this command needs a bit of clarification. It claims to update the extension of files, which it can be argued that it does that. But it doesn't really change the extension of files, does it? If there are files on the file system, they will be unchanged. It seems to only change the text in a table that contains file names. So, the file names are never changed with this command, correct? |
Yeah it doesn't change the file name locally. I updated the doc |
What do you think about naming this something like
Also, as I mentioned in the original feature request, this doesn't appear to handle "complex" extensions like we do with I still think that the following is so straightforward that I personally don't see much of a need for this as a 'sample.json' | path parse | $"($in.stem).nuon"
# => sample.nuon But I'll defer to others if they feel it's important. |
TBH I still think a command is good for it. And If using string interpolation approach, when we meet a list, it's required to use each: ['sample.json', 'sample2.json'] | path parse | each {|it| $"($it.stem).nuon"} Though it's not a big deal. I have renamed the command. |
path extension
to stdlib-candidatepath replace-extension
to stdlib-candidate
I say we land it, advertise it and ask for feedback via Showcase, and then evaluate in a month or so whether we want to promote it to |
I just noticed that this should be in the |
…nd with-parent (#1011) Extends #1002. Renames `path replace-extension` to `path with-extension`, in following with other languages ([Rust](https://doc.rust-lang.org/std/path/struct.Path.html#method.with_extension), [Python](https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.with_suffix)), and adds `path with-stem` and `path with-parent`. Also moves the `path` module into `std-rfc` so it can be used like `use std-rfc/path`. Adds a private helper function, `with-field`, that `with-extension`, `with-stem`, and `with-parent` can use. These can each be dead simple functions, while giving users more options for path manipulation. The motivation for separate `with-extension`, `with-stem`, and `with-parent` functions, rather than a more general function like `path with` is the following: - `with-extension` has special behavior for stripping periods - you can tab-complete `path with<TAB>` to immediately see all the possible options - you can't accidentally pass an invalid field to `path with` - there can be separate examples for `with-extension`, `with-stem`, `with-parent` for only the relevant functionality
This pr is trying to add a useful custom command which is mentioned here: nushell/nushell#14144
I think it's useful to play with file extensions.
This pr also set up testing for candidates. In order to do this, I made some changes:
nu-std/testing.nu
understdlib-candidate
folder, and making some changes.toolkit check pr
command, to make sure the test is run in CI.stdlib-candidate
toNU_LIB_DIRS
when running lint, so the tests can pass linter.Changes in stdlib-candidate/testing.nu:
std/log
usagestdlib-candidate
path inrun-test
command