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!(
strings::format::Format,
strings::format::FileSize,
strings::format::FormatDuration,
strings::encode_decode::EncodeHex,
strings::encode_decode::DecodeHex,
strings::str_::case::Str,

View File

@ -1,7 +1,3 @@
mod command;
mod duration;
mod filesize;
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,
StrTrim,
StrUpcase,
FormatDate
FormatDate,
FormatDuration,
FormatFilesize,
};
// FileSystem

View File

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

View File

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

View File

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