Move format duration/filesize back into core (#9978)

# Description
Those two commands are very complementary to `into duration` and `into
filesize` when you want to coerce a particular string output.

This keeps the old `format` command with its separate formatting syntax
still in `nu-cmd-extra`.

# User-Facing Changes
`format filesize` is back accessible with the default build. The new
`format duration` command is also available to everybody

# Tests + Formatting
This commit is contained in:
Stefan Holderbach 2023-08-10 20:01:47 +02:00 committed by GitHub
parent 23170ff368
commit a0cecf7658
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 11 deletions

View file

@ -85,8 +85,6 @@ pub fn add_extra_command_context(mut engine_state: EngineState) -> EngineState {
bind_command!( bind_command!(
strings::format::Format, strings::format::Format,
strings::format::FileSize,
strings::format::FormatDuration,
strings::encode_decode::EncodeHex, strings::encode_decode::EncodeHex,
strings::encode_decode::DecodeHex, strings::encode_decode::DecodeHex,
strings::str_::case::Str, strings::str_::case::Str,

View file

@ -1,7 +1,3 @@
mod command; mod command;
mod duration;
mod filesize;
pub(crate) use command::Format; pub(crate) use command::Format;
pub(crate) use duration::FormatDuration;
pub(crate) use filesize::FileSize;

View file

@ -192,7 +192,9 @@ pub fn add_shell_command_context(mut engine_state: EngineState) -> EngineState {
StrSubstring, StrSubstring,
StrTrim, StrTrim,
StrUpcase, StrUpcase,
FormatDate FormatDate,
FormatDuration,
FormatFilesize,
}; };
// FileSystem // FileSystem

View file

@ -19,9 +19,9 @@ impl CmdArgument for Arguments {
} }
#[derive(Clone)] #[derive(Clone)]
pub struct FileSize; pub struct FormatFilesize;
impl Command for FileSize { impl Command for FormatFilesize {
fn name(&self) -> &str { fn name(&self) -> &str {
"format filesize" "format filesize"
} }
@ -129,6 +129,6 @@ mod tests {
fn test_examples() { fn test_examples() {
use crate::test_examples; use crate::test_examples;
test_examples(FileSize) test_examples(FormatFilesize)
} }
} }

View file

@ -1,3 +1,7 @@
mod date; mod date;
mod duration;
mod filesize;
pub use self::filesize::FormatFilesize;
pub use date::FormatDate; pub use date::FormatDate;
pub use duration::FormatDuration;

View file

@ -10,7 +10,7 @@ mod str_;
pub use char_::Char; pub use char_::Char;
pub use detect_columns::*; pub use detect_columns::*;
pub use encode_decode::*; pub use encode_decode::*;
pub use format::FormatDate; pub use format::*;
pub use parse::*; pub use parse::*;
pub use size::Size; pub use size::Size;
pub use split::*; pub use split::*;