FEATURE: add the startup time to $nu#8353
Conversation
This is the easiest way i found to carry the startup around without changing a bunch of function arguments and function calls.
Important things to note: - i broken the `if` statement into two part, to only comput the startup_time once, otherwise, it would change as `nushell` gets older and older... - i use `EngineState.get_startup_time` in the banner to avoid re- computing the time elapsed > **Note** > i'm not super happy with the `let config = & ... .clone();` thing > but no idea how to make `cargo` happy here 🤔 > would love some feedback here!
This commit is here to allow `EngineState.set_startup_time` to take effet globally. Without these `&mut`, the `engine_state.startup_time` would not change really...
|
this is the script i talk about 😋 def banner [] {
$"(ansi green) __ ,(ansi reset)
(ansi green) .--\(\)°'.' (ansi reset)Welcome to (ansi green)Nushell(ansi reset),
(ansi green)'|, . ,' (ansi reset)based on the (ansi green)nu(ansi reset) language,
(ansi green) !_-\(_\\ (ansi reset)where all data is structured!
Please join our (ansi purple)Discord(ansi reset) community at (ansi purple)https://discord.gg/NtAbbGn(ansi reset)
Our (ansi green_bold)GitHub(ansi reset) repository is at (ansi green_bold)https://github.com/nushell/nushell(ansi reset)
Our (ansi green)Documentation(ansi reset) is located at (ansi green)https://nushell.sh(ansi reset)
(ansi cyan)Tweet(ansi reset) us at (ansi cyan_bold)@nu_shell(ansi reset)
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))
Startup Time: ($nu.startup-time)"
} |
|
@amtoine There are some small fixes that need to happen so the CI goes green. Do you have time for those? |
ooh i did not see the conflicts! |
…e-and-nu-variable
|
no more conflicts but still issues... and i cannot run the tests on my machine 'cause it overflows my RAM and swap 😭 |
|
okey it finally did compile, i can have a look at the issue 👍 |
|
i think this might be solved with 09ebf47 🤔 |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #8353 +/- ##
==========================================
- Coverage 68.49% 68.48% -0.02%
==========================================
Files 620 620
Lines 99480 99495 +15
==========================================
- Hits 68139 68135 -4
- Misses 31341 31360 +19
|
|
yeah 🥳 |
|
Thanks! |
👍 |
…ary (#8406) Related to: - #8311 - #8353 # Description with the new `$nu.startup-time` from #8353 and as mentionned in #8311, we are now able to fully move the `nushell` banner from the `rust` source base to the standard library. this PR - removes all the `rust` source code for the banner - rewrites a perfect clone of the banner to `std.nu`, called `std banner` - call `std banner` from `default_config.nu` # User-Facing Changes see the demo: https://asciinema.org/a/566521 - no config will show the banner (e.g. `cargo run --release -- --no-config-file`) - a custom config without the `if $env.config.show_banner` block and no call to `std banner` would never show the banner - a custom config with the block and `config.show_banner = true` will show the banner - a custom config with the block and `config.show_banner = false` will NOT show the banner # Tests + Formatting a new test line has been added to `tests.nu` to check the length of the `std banner` output. - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting ``` $nothing ``` --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Description
in #8311 and the discord server, the idea of moving the default banner from the
rustsource to thenushellstandar library has emerged 😋however, in order to do this, one need to have access to all the variables used in the default banner => all of them are accessible because known constants, except for the startup time of the shell, which is not anywhere in the shell...
this PR adds exactly this, i.e. the new
startup_timeto the$nuvariable, which is computed to have the exact same value as the value shown in the banner.the changes
in order to achieve this, i had to
startup_timeas ani64to theEngineState=> this is, to the best of my knowledge, the easiest way to pass such an information around down to where the banner startup time is computed and where the$nuvariable is evaluatedstartup-timeto the$nuvariable and use theEngineStategetter forstartup_timeto show it as aValue::Durationengine_stateas a&mutable argument frommain.rsdown torepl.rsto allow the setter to change the value ofstartup_time=> without this, the value would not change and would show-1nsas the default value...evaluate_replinrepl.rs, only once at the beginning, and the same value is used in the default banner 👌User-Facing Changes
one can now access to the same time as shown in the default banner with
$nu.startup-timeTests + Formatting
cargo fmt --allcargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collectcargo test --workspaceAfter Submitting