mirror of
https://github.com/nushell/nushell.git
synced 2025-05-17 08:20:49 +02:00
2590b22ae2
4 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
|
29eb109b1e
|
try to fix datetime-diff for ms, us, ns (#15537)
# Description This PR tries to fix the datetime-diff custom command so that it includes ms, us, ns. Difference in the banner in 2 separate starts. ### Old ```nushell It's been this long since Nushell's first commit: 5yrs 10months 29days 9hrs 1min 47secs ``` ### New ```nushell It's been this long since Nushell's first commit: 5yrs 10months 29days 9hrs 1min 22secs 49ms 885µs ``` There should be ns above on the new one, not sure why there isn't. It could have something to do with how the banner works but i'll save that for another PR. 🤔 It could be because there are no fractional seconds in the math? `datetime-diff (date now) 2019-05-10T09:59:12-07:00`. However, I'm not sure why `date now` has no nanoseconds. Oh, wait. I think that's because MacOS doesn't have nanosecond precision? ``` ❯ ^date +%s.%N 1744251636.365003000 ``` Closes https://github.com/nushell/nushell/issues/15524 /cc @NotTheDr01ds # User-Facing Changes <!-- List of all changes that impact the user experience here. This helps us keep track of breaking changes. --> # Tests + Formatting <!-- Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass (on Windows make sure to [enable developer mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging)) - `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` 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. --> |
||
|
442df9e39c
|
Custom command attributes (#14906)
# Description Add custom command attributes. - Attributes are placed before a command definition and start with a `@` character. - Attribute invocations consist of const command call. The command's name must start with "attr ", but this prefix is not used in the invocation. - A command named `attr example` is invoked as an attribute as `@example` - Several built-in attribute commands are provided as part of this PR - `attr example`: Attaches an example to the commands help text ```nushell # Double numbers @example "double an int" { 5 | double } --result 10 @example "double a float" { 0.5 | double } --result 1.0 def double []: [number -> number] { $in * 2 } ``` - `attr search-terms`: Adds search terms to a command - ~`attr env`: Equivalent to using `def --env`~ - ~`attr wrapped`: Equivalent to using `def --wrapped`~ shelved for later discussion - several testing related attributes in `std/testing` - If an attribute has no internal/special purpose, it's stored as command metadata that can be obtained with `scope commands`. - This allows having attributes like `@test` which can be used by test runners. - Used the `@example` attribute for `std` examples. - Updated the std tests and test runner to use `@test` attributes - Added completions for attributes # User-Facing Changes Users can add examples to their own command definitions, and add other arbitrary attributes. # Tests + Formatting - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting - Add documentation about the attribute syntax and built-in attributes - `help attributes` --------- Co-authored-by: 132ikl <132@ikl.sh> |
||
|
00709fc5bd
|
Improves startup time when using std-lib (#13842)
Updated summary for commit [ |
||
|
bc437da5c7
|
std dt datetime-diff: fix uninitialized field ref when borrowing (#10466)
fixes #10455 @KAAtheWiseGit, I'm sorry, I didn't mean to block your first PR #10461, didn't see you had submitted it till I got around to submitting this. If you want to incoporate useful ideas from this PR into yours, I do not mind deferring to you. # Description Changes made in `datetime-diff`: * Initialize millisecond and microsecond fields in `$current`, to fix the error when borrow needs to refer to them. * Fix `borrow_nanoseconds` to borrow from seconds, not from (unused) microseconds. * Added error check to insist that first argument is >= second argument. `datetime-diff` doesn't represent negative durations correctly (it tries to borrow out of the year, resulting in negative year and positive all other fields). We don't currently have a use case requiring negative durations. * Add comments so help is a bit clearer (I was surprised that the first argument, named `$from` was actually supposed to be the *later* datetime. The order of arguments is reasonable (reminiscent of <later> <minus> <earlier>), so I just changed the param name to match its purpose. Changes made in `pretty-print-duration`: * changed type of argument from `duration` to `record`. (it's not clear why Nu was not complaining about this!) * changed test for skipping a clause from `> 0` to `!= 0`. Even though `datetime-diff` won't present a negative field in the record, user might call `pretty-print-duration` with one, might as well handle it. (but I think `hour:-2` will be rendered as `-2hr`, not `-2hrs`...). * added help and an example. # User-Facing Changes none requiring code changes. # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` - - # 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. --> |