Repository navigation
Conversation
Real computations are missing and will be added later.
This commit calls the main "to nuon" function with - no argument when `--raw` is used - " " repeated $i$ times with the `--indent <i>` - "\t" repeated $t$ times with the `--tabs <t>`
This function does not add a depth level to the Value it's being given, it only - adds or removes quotes from a String - passes the Value to `value_to_string` again
This commit also makes `clippy` happy.
Commands used: ``` sd "to nuon\"" "to nuon --raw\"" **/*.rs git restore crates/nu-command/src/formats/to/nuon.rs ``` and some manuals tweaks as well.
This avoid hardcoding a " " in the field separation of the NUON output, leading in trailing whitespaces when newlines are enabled.
This is a temporary commit.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8366 +/- ##
==========================================
+ Coverage 68.53% 68.56% +0.02%
==========================================
Files 620 622 +2
Lines 99426 100631 +1205
==========================================
+ Hits 68145 68996 +851
- Misses 31281 31635 +354
|
This comment was marked as outdated.
This comment was marked as outdated.
|
i'm starting working on the => ok that was quite easy: solved in 4cc61df |
|
tests fixed in 0b4fad7 👌 |
This is to encourage the compactness of the NUON format: - by default, NUON will be printed in `--raw` format - adding `--indent` or `--tabs` will make NUON prettier, with the same precedence rules as before - adding `--raw` to any set of options will overwrite them and make the NUON output compact
This is related to previous commit.
…sults" This reverts commit 9159377. With previous commit, we do not need to impose `--raw`. This commit will make the overall diff much smaller.
|
in the four latest commits, i've made "raw" the default behaviour. the motivation comes from a remark of @fdncred i found very sensible!
in the end i did not implement a
changelog
🧪 all the tests pass locally |
|
Seems like a good thing. Thanks! |
yeaah 🥳 |
* Release notes for `0.78` Please add your new features and breaking changes to the release notes by opening PRs against the `release-notes-0.78` branch. * Document optional cell path members * Add placeholders * Mention empty list changes * Mention comparison operator breaking change * add a note about better `error make` (nushell#849) * Update 2023-04-04-nushell_0_78.md * Update 2023-04-04-nushell_0_78.md * Update 2023-04-04-nushell_0_78.md * Update 2023-04-04-nushell_0_78.md * Update 2023-04-04-nushell_0_78.md * Update 2023-04-04-nushell_0_78.md * Mention added `math exp` * Update 2023-04-04-nushell_0_78.md * Expand alias changes * add nushell#8366 to the release notes (nushell#848) * add nushell#8366 to the release note * make the title more explicit for the reader * be more explicit about what "pretty format" means * fix nuon quoting * Update 2023-04-04-nushell_0_78.md --------- Co-authored-by: Reilly Wood <[email protected]> Co-authored-by: Antoine Stevan <[email protected]> Co-authored-by: JT <[email protected]> Co-authored-by: Jakub Žádník <[email protected]>
This was introduced as nushell#8366 introduced a logic to have a priority of those flags (and have the `--raw` flag purely to match the flags on `to json`)
Should close #7255.
Description
TL;DR: this PR adds
--indent <int>,--tabs <int>and--rawto control a bit more thestringoutput ofto nuon, as done into jsonalready, the goal being to promote theNUONformat through easy to read and formatted output.nuonfiles 😋outside of
crates/nu-command/src/formats/to/nuon.rsas the signature of
value_to_stringhas changed, the single call to it outside of its module definition has been changed to use default values =>value_to_string(&value, Span::unknown(), 0, &None)incrates/nu-command/src/filters/uniq.rschanges to
ToNuonincrates/nu-command/src/formats/to/nuon.rs--raw,--indent <int>and--tabs <int>runmethod is inspired from the one into jsonValue--raw,--indentor--tabs, we call the conversion tostringwith different values of the indentation, starting at depth 0Okor aShellError::CantConvertdepending on the conversion resultget_true_indentationgives the full indentation =>indentrepeateddepthtimesget_true_separatorsgives the line and field separators => a("\n", "")when using some formatting or("", " ")when converting as pure string on a single linethe meat of
nuon.rsis now thevalue_to_stringrecursive function:depth + 1to increase the indentation by one levelnl,idt,idt_po(indent plus one) andidt_pt(indent plus two) to make theformat!s easier to readUser-Facing Changes
users can now
--indent <number of " " per level>--tabs <number of "\t" per level>to nuonwith the--rawoptionhelp to nuonTests + Formatting
new tests
to nuon, i.e. tests not of the form... | to nuon | from nuon ..., now use theto nuon --rawcommand => this is the smallest change to have the tests pass, as the newto nuon --rawis equivalent to the oldto nuoncrates/nu-command/src/formats/to/nuon.rs, the previous example has been replaced with three examples[1 2 3] | to nuonto show the default behaviour[1 2 3] | to nuon --rawto show the not-formatted output{date: 2000-01-01, data: [1 [2 3] 4.56]} | to nuonexamplestests passdev
cargo fmt --allcargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectcargo test --workspacepasses but withoutfixed in 0b4fad7to_nuon_errs_on_closureAfter Submitting
the
to nuonpage would have to be regenerated at some point due to the new tests