Repository navigation
Conversation
|
@DevWizard13 I've given you collaborator permissions on my fork. I need to rebase and clean up some failing tests, but if you could check into adding file extension support (I haven't figured out how) that would be awesome! |
c551adf to
6692eec
Compare
|
I'll get on that in a few minutes |
|
So it appears that it can automatically infer the file extension from the name of a command, as far as I can tell. As far as I can tell is the key phrase, this is a lot more advanced than most things I've dealt with before. I'm still getting my bearings in the codebase, so I'll return with a more detailed analysis in an hour or two. |
|
Yeah, it can automatically infer the file extension type if you put in a |
|
Test looks good. I've been able to both read and write RON files. I'll continue to use it and we'll see if we can get it merged. |
|
It can't yet read or write the size of a file. I'm going to implement this. |
Before, it couldn't write either of these values. It now achives feature parity with json in both, it can write Filesize as the number of bytes and Date as a string. The only problem left I can identify is that it seems to write dictionary items in alphabetical order rather than in the order they were provided. I will go through the list of nu data types and implement them all, where possible, comparing the results to to and from json.
Every type in nushell (besides closures, but those can't be saved to most file formats either) can now be saved to RON files.
|
Great! I edited the PR description since we don't need an explicit implementation for file extension support. |
45bfef7 to
855c6fb
Compare
|
I've now added a suite of integration tests and expanded the examples I wrote in my initial commit. I also want to note that we aren't retaining enum variants, and option mappings ( |
I used `to_string()` to format the date previously. I now use a function that uses the same format that is saved in json files. Also, I've tested it with a recod containing every data type nushell has (besides closures, which I don't think will be supported in the near future), the output of `ls -la`, and several random RON files I found floating around in my system. It works on all of them, as far as I can tell. I recommend running your own tests too. Either way, I think we've worked most of the problems out and we're to the testing and refinement phase. Most if not all of the development is done. It's basically reached feature parity with json support.
…l into feat/native-ron-support
|
You probably saw the commit, but I fixed the final few little things and tested it with multiple different tasks. It can read and write RON just as well as it can read and write JSON. The only thing that it doesn't do as well is that it seems to write records to the RON file in alphabetical order rather than in the order of the record, but this is honestly so minor I don't even think it's worth fixing. TLDR, it's done. I recommend testing it a little more just in case, but I'm pretty sure I've worked out everything. Great job! |
|
As for enums, I think it depends on what else we have to do. If we don't have anything else here to do, then yes, we should probably at least attempt to add them. If not, we should focus on those other things first. The type system of nushell unfortunately doesn't support enums, so our only options are to either find a way to serialize them to/from strings, to add enums to the nushell type system, or to ignore them. Serializing enums to and from strings would probably be difficult and risk accidentally treating normal strings as enums in the unlikely event that the syntax collided. Adding enums to the type system is the only reliable solution, but it would both be a giant pain to do and require coordination with the rest of the nushell team because it's a major change. Ignoring it would leave support out. So, I've thought about it, and I came to a decision. I think we should focus on stabilizing and merging what we have now, without worrying about Option or enums. Once we've done that, then we should ask the nushell team what they think of adding enums to the type system and make our decision about what to do with enums after that. Any thoughts, opinions, or objections? |
|
We could also represent enums as a record with a singular element, the name being the single key of the enum and the contents being whatever the enum contains. This is probably the cleanest and simplest solution, but it could also get difficult to work with once you've converted it to nu data types. It's probably the best solution yet. But I still stand by what I said earlier, we should probably focus on other things first. |
|
I completely agree with you, trying to introduce enums into Nushell's type system or making unstable patches would just blow up the scope and stall the PR. Let's get what we have stable, tested and merged first, and we can always change the enum handling at a later stage with the core team. As for the alphabetical record ordering, I believe that it stems from I've got the test suite ready to go, and haven't experienced any issues yet. I'll clean up the PR, and let's get this merged! |
|
Sounds good! |
|
To anyone impatient for this to hit the mainline and eventually the package manager of your system, I just compiled it, installed it to |
|
Oh, hey @nikooozzz your fork of nushell is out of date, I thought of updating it but I don't wanna risk breaking anything so can I update it? Also, you should enable issues there so that in the event someone wants to make future improvements or has things to discuss in it that don't belong here, we can do so outside the pull request. As a side note, fun plot twist (as you put it): someone actually read your blog! That's me. Life has a way of surprising us sometimes. Been a long time since I've seen someone just be themselves online rather than trying to perform for an algorithm, which is really nice. |
|
Sure! Feel free to update it. I was thinking it'd be better to have any issues be directly attached to the main repo instead of my fork, since people wouldn't want to go out of their way to find it and report through there when this gets merged. |
|
i could probably support this pr. can you get it green? if so i'll review it |
|
On it. |
nikooozzz
left a comment
There was a problem hiding this comment.
Just sat down to fix the ordering and dependency issues myself since I realized I hadn't refreshed the PR, great that you had already fixed them. On the struct question: I think we should serialize records as struct-like by default (as demonstrated by @fdncred) and fall back to quoted-key maps only for records whose keys aren't valid identifiers. Since Nu doesn't distinguish between structs and maps, a file mixing both won't roundtrip perfectly either way, but the PR advertises config files as the primary use case, so staying as close as possible to what serde structs and RON configs require seems right. I'll document the limitation in the to ron help text and the release notes as well.
|
Sounds good, but I'm not sure how to serialize a record to a RON struct, so I'll leave that one to you (or research it later if you don't get to it). But anyway, I think a fundamental issue here is that RON and nu have incompatible type systems, so we're gonna be fighting it a lot. |
## Description The `Security audit` job fails on PRs that touch `Cargo.toml` or `Cargo.lock` (seen on #19360). RUSTSEC-2026-0538 flags `quinn-udp 0.5.14`, and RUSTSEC-2026-0486 warns that `rustix 1.1.4` is unsound. This PR changes only `Cargo.lock`. | Crate | Old | New | Why | | --- | --- | --- | --- | | `quinn-udp` | 0.5.14 | 0.5.16 | RUSTSEC-2026-0538, receive loop can spin after a truncated datagram | | `rustix` | 1.1.4 | 1.1.6 | RUSTSEC-2026-0486, unsound xattr calls with a zero-length buffer | | `xattr` | 1.6.1 | 1.7.0 | `xattr 1.6.1` breaks on `rustix 1.1.6` | The `quinn-udp` bump alone turns the check green. The other two clear the unsound warning and have to move together. In `rustix 1.1.6`, `getxattr` and `listxattr` with an empty buffer return 0 instead of the size, which now comes from new `*_query` functions. `xattr 1.6.1` uses the empty-buffer call to size values over 4 KiB, and `xattr 1.7.0` uses `*_query` instead. nushell reaches this through `uucore::fsxattr` in `cp --preserve [xattr]` and cross-device `mv`. `cp --preserve [xattr]` on macOS, copying a file with a 6000-byte attribute: | Lockfile | Copied attribute | | --- | --- | | main (`rustix 1.1.4`, `xattr 1.6.1`) | 6000 bytes | | `rustix 1.1.6`, `xattr 1.6.1` | 0 bytes | | this PR (`rustix 1.1.6`, `xattr 1.7.0`) | 6000 bytes | ## User-facing changes (Release notes) <!-- This section is used (mostly as-is) for https://www.nushell.sh/blog/ Describe how Nushell behavior changes from a user's perspective. Do NOT describe internal Rust changes here. Write in a release note style, for example: - "Added support for..." - "Fixed an issue where..." - "Nushell now supports..." - "Improved performance of..." If your changes do NOT affect users (internal refactors, cleanup, etc.), just write: - "n/a" - "nan" - or similar This tells us the change should not appear in the changelog. Tips: - Focus on observable behavior - Include examples if helpful - Keep it concise You can: - Write a short paragraph (will appear as a bullet point), OR - Use headings (###) if your change needs more structure Avoid writing things like: - "In this PR, I refactored..." - "This updates internal code..." You may leave this blank until the PR is ready. --> ## Additional notes <!-- Optional. Examples: - fixes #123 - closes #456 - related #789 Anything else reviewers should know. Remove this section if not needed. -->
|
need to rebase to fix the security audit |
Before, it couldn't write either of these values. It now achives feature parity with json in both, it can write Filesize as the number of bytes and Date as a string. The only problem left I can identify is that it seems to write dictionary items in alphabetical order rather than in the order they were provided. I will go through the list of nu data types and implement them all, where possible, comparing the results to to and from json.
Every type in nushell (besides closures, but those can't be saved to most file formats either) can now be saved to RON files.
I used `to_string()` to format the date previously. I now use a function that uses the same format that is saved in json files. Also, I've tested it with a recod containing every data type nushell has (besides closures, which I don't think will be supported in the near future), the output of `ls -la`, and several random RON files I found floating around in my system. It works on all of them, as far as I can tell. I recommend running your own tests too. Either way, I think we've worked most of the problems out and we're to the testing and refinement phase. Most if not all of the development is done. It's basically reached feature parity with json support.
In the description of `from/ron.rs', I added a note to `description()` warning the user that it cannot parse enums and that `Some` is expanded automatically.
RON is now a workspace dependency, and ordering is preserved instead of being overriden by alphabetical order.
Unix newlines (LF) and tabs ("\t") are now standard for the pretty
config.
It now reports errors as the error rather than as an unsupported type.
It conuses me as to why it was messed up to start with, but it was. Fixed it.
Remove unnecessary borrow. Co-authored-by: Darren Schroeder <[email protected]>
Add glob support (as a string) Co-authored-by: Darren Schroeder <[email protected]>
534084e to
f146749
Compare
|
So, about the struct thing, I did some looking and I don't think it's going to be possible anytime soon. There is no struct type in Basically, I think that this is more of a long-term goal. I've talked about this before, but RON and nu have fundamentally incompatible type systems. We're probably not going to get data to roundtrip through it anytime soon. I think that we should focus on getting something that works before we get something that's perfect. So, I think the best approach would be to focus on stabilizing and merging what we have, accept that for the time being, it will be primarily for reading RON and that the write functionality will be relatively limited. We should, however, also discuss what we want this to look like in the long term. However, let's focus on getting stuff working right now. What do you think about this? |
…l into feat/native-ron-support
|
Also, about the struct vs map thing, I talked with the maintainers of RON and it's not an issue with RON, it's an issue with serde. Serde requires I generally got the message that while they hope it's going to happen eventually, they're waiting on serde and it doesn't seem to be happening quickly. So, we'll probably have to implement something ourselves or wait for support from serde. |
|
Makes complete sense. Given how |
Description
This PR introduces native support for RON (Rusty Object Notation) in Nushell by adding two new core format commands:
from ron: Parses RON string data into structured Nushell values (records, lists, primitives).to ron: Serializes Nushell structured data (records, lists, primitives) into pretty-printed or raw RON text.This enables seamless pipelines for parsing and serializing RON configuration files and data structures directly within Nushell.
User-facing changes (Release notes)
from ronandto roncommands to natively support parsing and serializing Rusty Object Notation (RON) data formats.Checklist
from roncommandto roncommandAdditional notes