mirror of
https://github.com/nushell/nushell.git
synced 2024-12-12 02:02:32 +01:00
14bf25da14
# Description Closes: #9891 I also think it's good to keep command name consistency. And moving `date format` to deprecated. # User-Facing Changes Running `date format` will lead to deprecate message: ```nushell ❯ "2021-10-22 20:00:12 +01:00" | date format Error: nu:🐚:deprecated_command × Deprecated command date format ╭─[entry #28:1:1] 1 │ "2021-10-22 20:00:12 +01:00" | date format · ─────┬───── · ╰── 'date format' is deprecated. Please use 'format date' instead. ╰──── ```
21 lines
427 B
Plaintext
21 lines
427 B
Plaintext
export def now [] {
|
|
date now | format date "%Y-%m-%dT%H:%M:%S%.3f"
|
|
}
|
|
|
|
export def format-message [
|
|
message: string,
|
|
format: string
|
|
prefix: string,
|
|
ansi
|
|
] {
|
|
[
|
|
["%MSG%" $message]
|
|
["%DATE%" (now)]
|
|
["%LEVEL%" $prefix]
|
|
["%ANSI_START%" $ansi]
|
|
["%ANSI_STOP%" (ansi reset)]
|
|
] | reduce --fold $format {
|
|
|it, acc| $acc | str replace --all $it.0 $it.1
|
|
}
|
|
}
|