-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
cp
: make more types public and add more documentation (for nushell)
#5152
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
f686ceb
to
ffa08f4
Compare
GNU testsuite comparison:
|
Thanks @tertsdiepraam for putting up this PR to support us. I'm excited to see where this leads. I'll try to look at it soon, maybe this weekend. |
Hi @tertsdiepraam , first of all the hard work. I have indeed been working on this on the background, but I go slow since I dont have much time available, plus being still not a seasoned rust developer. But I try to work on it a bit certain days and make progress. please see my branch with some extra implementation taken from the So couple of things
Slightly less relevant but important:
There might be some things here that are not strictly related to your PR, but it might help us identifying where we should help each other more, and how to go about it in the future! |
That PR looks great! I think we can combine that with this PR. Two thoughts:
Do you think you can simplify your branch so that we can turn it into a PR for nu? Just take all the arguments that are easy to implement and leave the rest as TODO. |
@dmatos2012 Wow, great work! Thanks so much for putting in the time and effort! I'm perfectly happy to close my prototype PR in favor of yours if you'd want to submit it to nushell after some minor changes. I'm pretty much in the same camp as @tertsdiepraam. Let's do the I lean towards not being 100% GNU parameter compliant, but it would be nice if we can offer the same things but with slightly different flags/parameters at some point. For now, I think it would be great to get a PR up in nushell with all the cp tests this code supports. |
@dmatos2012 How shall we proceed? I can probably put up a PR based on your branch in the next couple of days or do you want to do that? @fdncred If we want to get this in the next nushell release, what us our deadline? If the next release is soon, we might have to aim for the next one, since we'll have to do a new release of uutils for this to work too (since the changes to Edit: Another issue is MSRV. We currently have 1.64 and nushell seems to have 1.60 as MSRV. What is nushell's MSRV policy? |
Hey @tertsdiepraam , I was thinking on still doing it, I have made some progress by adding more tests, see latest commit, but I want to add all the other tests to cover all the flags as @fdncred mentioned. I do not intend to add more flags that are there. I think by end of this week it should be possible to have it ready, but yeah can only work on it certain nights, of course only after my day job. Its only some extra tests, and checking the use of flags is ok for the Nu people as well. One key thing that I am currently missing is how to get the Let me know your thoughts :) |
Excellent! I'll leave it to you then. In the meantime, I'll update this PR with a solution for |
@tertsdiepraam Here's some info.
|
Alright, let's aim for the release after the next one then. I'm glad that MSRV won't be an issue. Thanks for the info! |
Re: Attributes Here's an interesting consideration: do you want the attributes to be given as a nu list? I.e. should
or like this:
Or should both be supported? And if the first is chosen, is |
My first choice would be to use a nushell list, keeping things nushell-y. I'd also be ok with the shorthand. |
Clean up the parsing of the attributes to preserve. There are several improvements here: Preserve now uses `max` from Ord, the `max` method is now called `union` and does not mutate, the parse loop is extracted into a new function `parse_iter`, the `all` and `none` methods are replaced with const values. Finally all fields of Attributes are now public.
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.
Looks good, though I can't judge whether these changes meet the requirements of nushell.
@dmatos2012 not trying to rush you, just checking in on your progress. wondering if you've been able to test with these latest changes to attributes? |
@fdncred as far as I can tell, the changes @tertsdiepraam made are perfect for us. Now with I have implemented the parsing, but still writing tests to confirm! I have tried manually some of hte attributes and everything looks ok so far! Once I submit my PR to nushell (somewhere this weekend maybe?), we can keep adding stuff and going from there. Apologies for the time im taking, but well some other things going on as well and limited time. Thanks! |
Sounds good. Thanks for the update. No apologies necessary. @tertsdiepraam What's the plan to land this PR and do a release? It appears that things are working good. Although I haven't seen the PR. Do you want to wait until there's a nushell PR so we can get some more testing in to make sure this PR is solid or are you ready now? Also, I'm not sure of your release schedule/cadence. |
@fdncred My initial plan was:
However, I think we can just land this PR because it's fairly straightforward. If there's more to do we can open more PRs :) Our release cadence is roughly 6 weeks, but it's not fixed. The next one would be due in roughly 2 weeks. I wouldn't mind releasing earlier (but the other maintainers would have to agree). |
Thanks for the info and for this PR! We have a release on August 22 and then one 4 weeks after that. So, your cadence will probably fit within ours. We appreciate your support and help. |
Hi @fdncred and @tertsdiepraam I have made draft PR on nushell. Check it out, and let me know your thoughts. Thanks for the patience, but yeah decided to just do this rather than wait to make it "nicer" ! |
Thanks @dmatos2012. Already skimmed it and made a brief comment. |
) <!-- if this PR closes one or more issues, you can automatically link the PR with them by using one of the [*linking keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword), e.g. - this PR should close #xxxx - fixes #xxxx you can also mention related issues, PRs or discussions! --> # Description Hi. Basically, this is a continuation of the work that @fdncred started. Given some nice discussions on #9463 , and [merged uutils PR](uutils/coreutils#5152) from @tertsdiepraam we have decided to give the `cp` command the `crawl` stage as it was named. > [!NOTE] Given that the `uutils` crate has not made the release for the merged PR, just make sure you checkout latest and put it in the required place to make this PR work. The aim of this PR is for is to see how to move forward using `uutils` crate. In order to getting this started, I have made the current `nushell cp tests` pass along with some extra ones I copied over from the `uutils` repo. With all of that being said, things that would be nice to decide, and keep working on: Crawl: - Handling of certain `named` flags, with their long and short forms(e.g. --update, --reflink, --preserve, etc), and using default values. Maybe `-u` can already have a `default_missing_value`. - Should we maybe just support one single option `switch` flags (see `--backup` in code) as a contrast to the other named args. - Complete test coverage from `uutils`. They had > 100 tests, and I could only port like 12 as they are a bit time consuming given they cannot be straight up copy pasted. Maybe we do not need all >100, but maybe the more relevant to what we want. - Refactor this code Walk: - Non fatal errors on `copy` from `utils`. Currently it just sends it to stdout but errors have no span - Better integration An added possibility is the addition of `SyntaxShape::OneOf()` for `Named` arguments which was briefly mentioned in the discord server, but that is still to be decided. This could greatly improve some of the integration. This would enable something like `cp --preserve [all timestamp]` or `cp --preserve all` to both work. I did not want to keep holding on this, and wait till I was happy with the code because I think its nice if everyone can start up and suggest refactors, but the main important part now was getting it out the door, as if I take my sweet time this will take way longer 😛 <!-- Thank you for improving Nushell. Please, check our [contributing guide](../CONTRIBUTING.md) and talk to the core team before making major changes. Description of your pull request goes here. **Provide examples and/or screenshots** if your changes affect the user experience. --> # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting Make sure you've run and fixed any issues with these commands: - [X] cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - [X] cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - [X] cargo test --workspace` to check that all tests pass - [X] cargo run -- -c "use std testing; testing run-tests --path crates/nu-std"` to run the tests for the standard library > **Note** > from `nushell` you can also use the `toolkit` as follows > ```bash > use toolkit.nu # or use an `env_change` hook to activate it automatically > toolkit check pr > ``` --> # After Submitting <!-- If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --> --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Part of #5088.
I've removed the
Source
,SourceSlice
,Target
andTargetSlice
type aliases, because I think those obfuscate the public API. I want to make it as easy as possible for the nushell people to understand how to use our types and functions, without having to dive into the source code. For the same reason, I've documented every field of theOptions
struct with the arguments that change the behavior. Various other docstrings are added or improved too.While theAttributes
struct ispub
, nu won't be able to construct it yet. We'll have to discuss whether they want to do their own parsing there or that we should do it (i.e. should we make all the fieldspub
or should we provide some functions to set the values).Attributes
can now be constructed either:Attributes::parse_iter
method which takes an iterator of strings,Attributes::{ALL, NONE, LINKS}
This PR also cleans up attribute parsing in general. It should therefore receive additional attention in code review. Those changes are in a separate commit.
@dmatos2012 I figured you weren't actively working on this anymore, so I picked it up. If you have a branch with changes ready, let's discuss how we can get the best of both versions.
@fdncred Does this look like something you can work with? I'd be happy to help out with the PR on the nu side.
Some final notes:
cp
is particularly well-suited for this purpose with a clear single function, a goodOptions
struct andError
type.UResult
yet. That might be something to tackle later.