REFACTOR: move the banner from the rust source to the standard library#8406
Conversation
|
Nice work @amtoine! However, I don't want to remove this until we start distributing the stdlib as default (just like you said above). So, with that in mind, I'm marking this a draft to prevent accidental merging. |
oh yeah you're right! let's avoid an accidental merge 😌 |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8406 +/- ##
==========================================
+ Coverage 68.84% 68.92% +0.07%
==========================================
Files 641 641
Lines 102321 102231 -90
==========================================
+ Hits 70444 70463 +19
+ Misses 31877 31768 -109
|
| Learn how to remove this at: (ansi green)https://nushell.sh/book/configuration.html#remove-welcome-message(ansi reset) | ||
|
|
||
| It's been this long since (ansi green)Nushell(ansi reset)'s first commit: | ||
| ((date now) - ('2019-05-10 09:59:12-0700' | into datetime)) |
There was a problem hiding this comment.
You can use the datetime value here instead of using into datetime
(date now) - 2019-05-10T09:59:12-07:00)
There was a problem hiding this comment.
ooh yes indeed!
let me switch to this simpler solution 👍
This is from a comment of @jntrnr.
This should solve the merge conflicts in nushell#8406.
|
the three commits above should
|
This is to avoid printing something on the same line as the time. I have a hook that triggers automatically when entering a directory and running `cargo run --release` gave me ``` ... Startup Time: -1nstoolkit module detected... activating toolkit module with `use toolkit.nu` ``` before this commit. now i get ``` ... Startup Time: -1ns toolkit module detected... activating toolkit module with `use toolkit.nu` ```
|
💡 one thing we could do here is to remove the to disable the banner, a user just have to either
what do you think? 😋 |
This should also fix the CI and the `test_config_path::test_alternate_config_path` test, see https://github.com/nushell/nushell/actions/runs/4828641085/jobs/8602701650?pr=8406
@fdncred found that 1. setting the PWD in the engine state solved the tests 2. not setting it in the stack did not change anything let's see what the CI thinks of this 😋
I'd prefer to implement with a clone with what we have today, 100% same functionality, just working from std lib vs rust code. Then, at a later time, if we want to make the changes you're suggestion, we could do that. I think it's better to just move one step at a time first. |
It gets complicated, so complicated that i cannot remember when defaults are sourced and not. you'll have to do some research i guess. |
|
okey, i think i have a fix 😏 how it behaves nowwhere and the actual two changes |
|
it might be not perfect but that works and the banner has been moved to |
fdncred
left a comment
There was a problem hiding this comment.
I've tested this and it looks identical to the original. Good work!
glad you like it 🥳 do we want the point of view of another member of the team? |
sholderbach
left a comment
There was a problem hiding this comment.
You can now not run the default config with --no-std-lib:
As this call is in the rust code and not in the config this should be fixed on the Rust side in my view.
~/nushell> cargo run -- --no-std-lib
Finished dev [unoptimized + debuginfo] target(s) in 0.16s
Running `target/debug/nu --no-std-lib`
Error: nu::parser::module_not_found
× Module not found.
╭─[show_banner:1:1]
1 │ use std banner; banner
· ─┬─
· ╰── module not found
╰────
help: module files and their paths must be available before your script is run as parsing occurs before anything
is evaluated
very good catch! 😮 what should be the behaviour of the banner with |
|
At a minimum, I think it's helpful to always have startup time. It's a benchmark metric that need to keep track of like this. It's an easy way to measure some startup performance areas.
|
|
@sholderbach
we always can run the following to run performance benchmarks! nu -c "print $nu.startup-time"
nu --no-std-lib -c "print $nu.startup-time"
nu -n -c "print $nu.startup-time"
nu -n --no-std-lib -c "print $nu.startup-time"or run i do not think we should require this from the banner 🤔 |
|
That's fine. I forgot we were storing it in $nu. |
|
I have another change I'd like to make. I may try to add to this PR if that's ok? |
sure go ahead 😌
i've ticked the Allow edits and access to secrets by maintainers box above, tell me if that's ok to edit this branch 😋 |
|
Updated with JT's better date math script + some tweaks. But note, there's a bug somewhere I think because nanoseconds is always zero, which is why it's left out. I think it's something internal to how we're handling dates versus the scripting. @amtoine Feel free to reorganize/rename or whatever. I just wanted to get the better math in there until Bob can fix our internal rust date math. |
|
i'll make this a DRAFT again for now. just a question, where does this script come from? 😋 |
I said above. JT wrote most of it and I tweaked it. I'm ready to land it once you give it a look. |
|
I'm seeing a little bit of cleanup work that needs to be done. There's a comment that I need to remove and we should think about maybe making a function in dt.nu that formats the duration string so we don't end up with this (which i just happened to get in Windows)
|
|
Let's give this a try while we still have a few days before the release. |


Related to:
$nu#8353Description
with the new
$nu.startup-timefrom #8353 and as mentionned in #8311, we are now able to fully move thenushellbanner from therustsource base to the standard library.this PR
rustsource code for the bannerstd.nu, calledstd bannerstd bannerfromdefault_config.nuUser-Facing Changes
see the demo: https://asciinema.org/a/566521
cargo run --release -- --no-config-file)if $env.config.show_bannerblock and no call tostd bannerwould never show the bannerconfig.show_banner = truewill show the bannerconfig.show_banner = falsewill NOT show the bannerTests + Formatting
a new test line has been added to
tests.nuto check the length of thestd banneroutput.toolkit fmttoolkit clippytoolkit testtoolkit test stdlibAfter Submitting