diff --git a/dev/src/uu_dd/progress.rs.html b/dev/src/uu_dd/progress.rs.html index 5e341fc15..84a52d0dc 100644 --- a/dev/src/uu_dd/progress.rs.html +++ b/dev/src/uu_dd/progress.rs.html @@ -631,6 +631,31 @@ 631 632 633 +634 +635 +636 +637 +638 +639 +640 +641 +642 +643 +644 +645 +646 +647 +648 +649 +650 +651 +652 +653 +654 +655 +656 +657 +658
//  * This file is part of the uutils coreutils package.
 //  *
 //  * For the full copyright and license information, please view the LICENSE
@@ -646,6 +671,9 @@
 use std::sync::mpsc;
 use std::time::Duration;
 
+use uucore::error::UResult;
+use uucore::memo::sprintf;
+
 use crate::numbers::{to_magnitude_and_suffix, SuffixType};
 
 // On Linux, we register a signal handler that prints progress updates.
@@ -764,7 +792,7 @@
     /// prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
     /// assert_eq!(cursor.get_ref(), b"0 bytes copied, 1.0 s, 0.0 B/s\n");
     /// ```
-    fn write_prog_line(&self, w: &mut impl Write, rewrite: bool) -> std::io::Result<()> {
+    fn write_prog_line(&self, w: &mut impl Write, rewrite: bool) -> UResult<()> {
         // The total number of bytes written as a string, in SI and IEC format.
         let btotal = self.write_stat.bytes_total;
         let btotal_metric = to_magnitude_and_suffix(btotal, SuffixType::Si);
@@ -781,27 +809,31 @@
         // (`\n`) at the end.
         let (carriage_return, newline) = if rewrite { ("\r", "") } else { ("", "\n") };
 
+        // The duration should be formatted as in `printf %g`.
+        let duration_str = sprintf("%g", &[duration.to_string()])?;
+
         // If the number of bytes written is sufficiently large, then
         // print a more concise representation of the number, like
         // "1.2 kB" and "1.0 KiB".
         match btotal {
             1 => write!(
                 w,
-                "{carriage_return}{btotal} byte copied, {duration:.1} s, {transfer_rate}/s{newline}",
-            ),
+                "{carriage_return}{btotal} byte copied, {duration_str} s, {transfer_rate}/s{newline}",
+            )?,
             0..=999 => write!(
                 w,
-                "{carriage_return}{btotal} bytes copied, {duration:.1} s, {transfer_rate}/s{newline}",
-            ),
+                "{carriage_return}{btotal} bytes copied, {duration_str} s, {transfer_rate}/s{newline}",
+            )?,
             1000..=1023 => write!(
                 w,
-                "{carriage_return}{btotal} bytes ({btotal_metric}) copied, {duration:.1} s, {transfer_rate}/s{newline}",
-            ),
+                "{carriage_return}{btotal} bytes ({btotal_metric}) copied, {duration_str} s, {transfer_rate}/s{newline}",
+            )?,
             _ => write!(
                 w,
-                "{carriage_return}{btotal} bytes ({btotal_metric}, {btotal_bin}) copied, {duration:.1} s, {transfer_rate}/s{newline}",
-            ),
-        }
+                "{carriage_return}{btotal} bytes ({btotal_metric}, {btotal_bin}) copied, {duration_str} s, {transfer_rate}/s{newline}",
+            )?,
+        };
+        Ok(())
     }
 
     /// Write all summary statistics.
@@ -833,7 +865,7 @@
     /// assert_eq!(iter.next().unwrap(), b"");
     /// assert!(iter.next().is_none());
     /// ```
-    fn write_transfer_stats(&self, w: &mut impl Write, new_line: bool) -> std::io::Result<()> {
+    fn write_transfer_stats(&self, w: &mut impl Write, new_line: bool) -> UResult<()> {
         if new_line {
             writeln!(w)?;
         }
@@ -1129,6 +1161,15 @@
         }
     }
 
+    fn prog_update_duration(duration: Duration) -> ProgUpdate {
+        ProgUpdate {
+            read_stat: Default::default(),
+            write_stat: Default::default(),
+            duration: duration,
+            complete: false,
+        }
+    }
+
     #[test]
     fn test_read_stat_report() {
         let read_stat = ReadStat::new(1, 2, 3);
@@ -1185,24 +1226,24 @@
         //     0 bytes copied, 7.9151e-05 s, 0.0 kB/s
         //
         // The throughput still does not match GNU dd.
-        assert_eq!(cursor.get_ref(), b"0 bytes copied, 1.0 s, 0.0 B/s\n");
+        assert_eq!(cursor.get_ref(), b"0 bytes copied, 1 s, 0.0 B/s\n");
 
         let prog_update = prog_update_write(1);
         let mut cursor = Cursor::new(vec![]);
         prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
-        assert_eq!(cursor.get_ref(), b"1 byte copied, 1.0 s, 0.0 B/s\n");
+        assert_eq!(cursor.get_ref(), b"1 byte copied, 1 s, 0.0 B/s\n");
 
         let prog_update = prog_update_write(999);
         let mut cursor = Cursor::new(vec![]);
         prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
-        assert_eq!(cursor.get_ref(), b"999 bytes copied, 1.0 s, 0.0 B/s\n");
+        assert_eq!(cursor.get_ref(), b"999 bytes copied, 1 s, 0.0 B/s\n");
 
         let prog_update = prog_update_write(1000);
         let mut cursor = Cursor::new(vec![]);
         prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
         assert_eq!(
             cursor.get_ref(),
-            b"1000 bytes (1.0 kB) copied, 1.0 s, 1.0 kB/s\n"
+            b"1000 bytes (1.0 kB) copied, 1 s, 1.0 kB/s\n"
         );
 
         let prog_update = prog_update_write(1023);
@@ -1210,7 +1251,7 @@
         prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
         assert_eq!(
             cursor.get_ref(),
-            b"1023 bytes (1.0 kB) copied, 1.0 s, 1.0 kB/s\n"
+            b"1023 bytes (1.0 kB) copied, 1 s, 1.0 kB/s\n"
         );
 
         let prog_update = prog_update_write(1024);
@@ -1218,7 +1259,7 @@
         prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
         assert_eq!(
             cursor.get_ref(),
-            b"1024 bytes (1.0 kB, 1.0 KiB) copied, 1.0 s, 1.0 kB/s\n"
+            b"1024 bytes (1.0 kB, 1.0 KiB) copied, 1 s, 1.0 kB/s\n"
         );
     }
 
@@ -1237,7 +1278,7 @@
         let mut iter = cursor.get_ref().split(|v| *v == b'\n');
         assert_eq!(iter.next().unwrap(), b"0+0 records in");
         assert_eq!(iter.next().unwrap(), b"0+0 records out");
-        assert_eq!(iter.next().unwrap(), b"0 bytes copied, 1.0 s, 0.0 B/s");
+        assert_eq!(iter.next().unwrap(), b"0 bytes copied, 1 s, 0.0 B/s");
         assert_eq!(iter.next().unwrap(), b"");
         assert!(iter.next().is_none());
     }
@@ -1256,13 +1297,22 @@
         prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
         prog_update.write_transfer_stats(&mut cursor, true).unwrap();
         let mut iter = cursor.get_ref().split(|v| *v == b'\n');
-        assert_eq!(iter.next().unwrap(), b"\r0 bytes copied, 1.0 s, 0.0 B/s");
+        assert_eq!(iter.next().unwrap(), b"\r0 bytes copied, 1 s, 0.0 B/s");
         assert_eq!(iter.next().unwrap(), b"0+0 records in");
         assert_eq!(iter.next().unwrap(), b"0+0 records out");
-        assert_eq!(iter.next().unwrap(), b"0 bytes copied, 1.0 s, 0.0 B/s");
+        assert_eq!(iter.next().unwrap(), b"0 bytes copied, 1 s, 0.0 B/s");
         assert_eq!(iter.next().unwrap(), b"");
         assert!(iter.next().is_none());
     }
+
+    #[test]
+    fn test_duration_precision() {
+        let prog_update = prog_update_duration(Duration::from_nanos(123));
+        let mut cursor = Cursor::new(vec![]);
+        let rewrite = false;
+        prog_update.write_prog_line(&mut cursor, rewrite).unwrap();
+        assert_eq!(cursor.get_ref(), b"0 bytes copied, 1.23e-07 s, 0.0 B/s\n");
+    }
 }
 
\ No newline at end of file diff --git a/dev/src/uu_expand/expand.rs.html b/dev/src/uu_expand/expand.rs.html index cb66a26db..ee7d6b78b 100644 --- a/dev/src/uu_expand/expand.rs.html +++ b/dev/src/uu_expand/expand.rs.html @@ -506,7 +506,6 @@ 506 507 508 -509
// This file is part of the uutils coreutils package.
 //
 // (c) Virgile Andreani <virgile.andreani@anbuco.fr>
@@ -528,11 +527,10 @@
 use unicode_width::UnicodeWidthChar;
 use uucore::display::Quotable;
 use uucore::error::{FromIo, UError, UResult};
-use uucore::{crash, format_usage};
+use uucore::{crash, format_usage, help_about, help_usage};
 
-static ABOUT: &str = "Convert tabs in each FILE to spaces, writing to standard output.
- With no FILE, or when FILE is -, read standard input.";
-const USAGE: &str = "{} [OPTION]... [FILE]...";
+const ABOUT: &str = help_about!("expand.md");
+const USAGE: &str = help_usage!("expand.md");
 
 pub mod options {
     pub static TABS: &str = "tabs";
diff --git a/dev/src/uu_false/false.rs.html b/dev/src/uu_false/false.rs.html
index 460d42e50..8eb5bb62d 100644
--- a/dev/src/uu_false/false.rs.html
+++ b/dev/src/uu_false/false.rs.html
@@ -65,11 +65,6 @@
 65
 66
 67
-68
-69
-70
-71
-72
 
//  * This file is part of the uutils coreutils package.
 //  *
 //  * (c) Jordi Boggiano <j.boggiano@seld.be>
@@ -79,14 +74,9 @@
 use clap::{Arg, ArgAction, Command};
 use std::{ffi::OsString, io::Write};
 use uucore::error::{set_exit_code, UResult};
+use uucore::help_about;
 
-static ABOUT: &str = "\
-Returns false, an unsuccessful exit status.
-
-Immediately returns with the exit status `1`. When invoked with one of the recognized options it
-will try to write the help or version text. Any IO error during this operation is diagnosed, yet
-the program will also return `1`.
-";
+const ABOUT: &str = help_about!("false.md");
 
 #[uucore::main]
 pub fn uumain(args: impl uucore::Args) -> UResult<()> {
diff --git a/dev/src/uu_groups/groups.rs.html b/dev/src/uu_groups/groups.rs.html
index 2442ee8b6..fd54b7cd4 100644
--- a/dev/src/uu_groups/groups.rs.html
+++ b/dev/src/uu_groups/groups.rs.html
@@ -110,9 +110,6 @@
 110
 111
 112
-113
-114
-115
 
// This file is part of the uutils coreutils package.
 //
 // (c) Alan Andrade <alan.andradec@gmail.com>
@@ -136,7 +133,7 @@
     display::Quotable,
     entries::{get_groups_gnu, gid2grp, Locate, Passwd},
     error::{UError, UResult},
-    format_usage, show,
+    format_usage, help_about, help_usage, show,
 };
 
 use clap::{crate_version, Arg, ArgAction, Command};
@@ -144,11 +141,8 @@
 mod options {
     pub const USERS: &str = "USERNAME";
 }
-static ABOUT: &str = "Print group memberships for each USERNAME or, \
-                      if no USERNAME is specified, for\nthe current process \
-                      (which may differ if the groups data‐base has changed).";
-
-const USAGE: &str = "{} [OPTION]... [USERNAME]...";
+const ABOUT: &str = help_about!("groups.md");
+const USAGE: &str = help_usage!("groups.md");
 
 #[derive(Debug)]
 enum GroupsError {
diff --git a/dev/uu_expand/fn.uu_app.html b/dev/uu_expand/fn.uu_app.html
index f55cb2152..29659da1d 100644
--- a/dev/uu_expand/fn.uu_app.html
+++ b/dev/uu_expand/fn.uu_app.html
@@ -1 +1 @@
-uu_app in uu_expand - Rust

Function uu_expand::uu_app

source ·
pub fn uu_app() -> Command
\ No newline at end of file +uu_app in uu_expand - Rust

Function uu_expand::uu_app

source ·
pub fn uu_app() -> Command
\ No newline at end of file diff --git a/dev/uu_expand/fn.uumain.html b/dev/uu_expand/fn.uumain.html index 10291af8e..2983e134f 100644 --- a/dev/uu_expand/fn.uumain.html +++ b/dev/uu_expand/fn.uumain.html @@ -1 +1 @@ -uumain in uu_expand - Rust

Function uu_expand::uumain

source ·
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file +uumain in uu_expand - Rust

Function uu_expand::uumain

source ·
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file diff --git a/dev/uu_expand/index.html b/dev/uu_expand/index.html index fcf979b40..70234228e 100644 --- a/dev/uu_expand/index.html +++ b/dev/uu_expand/index.html @@ -1 +1 @@ -uu_expand - Rust
\ No newline at end of file +uu_expand - Rust
\ No newline at end of file diff --git a/dev/uu_expand/options/index.html b/dev/uu_expand/options/index.html index f019fbc84..c635fd029 100644 --- a/dev/uu_expand/options/index.html +++ b/dev/uu_expand/options/index.html @@ -1 +1 @@ -uu_expand::options - Rust
\ No newline at end of file +uu_expand::options - Rust
\ No newline at end of file diff --git a/dev/uu_expand/options/static.FILES.html b/dev/uu_expand/options/static.FILES.html index 8d839777c..49a417d51 100644 --- a/dev/uu_expand/options/static.FILES.html +++ b/dev/uu_expand/options/static.FILES.html @@ -1 +1 @@ -FILES in uu_expand::options - Rust

Static uu_expand::options::FILES

source ·
pub static FILES: &str
\ No newline at end of file +FILES in uu_expand::options - Rust

Static uu_expand::options::FILES

source ·
pub static FILES: &str
\ No newline at end of file diff --git a/dev/uu_expand/options/static.INITIAL.html b/dev/uu_expand/options/static.INITIAL.html index 07a3992a0..e377d11fc 100644 --- a/dev/uu_expand/options/static.INITIAL.html +++ b/dev/uu_expand/options/static.INITIAL.html @@ -1 +1 @@ -INITIAL in uu_expand::options - Rust

Static uu_expand::options::INITIAL

source ·
pub static INITIAL: &str
\ No newline at end of file +INITIAL in uu_expand::options - Rust

Static uu_expand::options::INITIAL

source ·
pub static INITIAL: &str
\ No newline at end of file diff --git a/dev/uu_expand/options/static.NO_UTF8.html b/dev/uu_expand/options/static.NO_UTF8.html index 874a8301a..a549f6a19 100644 --- a/dev/uu_expand/options/static.NO_UTF8.html +++ b/dev/uu_expand/options/static.NO_UTF8.html @@ -1 +1 @@ -NO_UTF8 in uu_expand::options - Rust

Static uu_expand::options::NO_UTF8

source ·
pub static NO_UTF8: &str
\ No newline at end of file +NO_UTF8 in uu_expand::options - Rust

Static uu_expand::options::NO_UTF8

source ·
pub static NO_UTF8: &str
\ No newline at end of file diff --git a/dev/uu_expand/options/static.TABS.html b/dev/uu_expand/options/static.TABS.html index 0a48e2ea1..ad3e449e2 100644 --- a/dev/uu_expand/options/static.TABS.html +++ b/dev/uu_expand/options/static.TABS.html @@ -1 +1 @@ -TABS in uu_expand::options - Rust

Static uu_expand::options::TABS

source ·
pub static TABS: &str
\ No newline at end of file +TABS in uu_expand::options - Rust

Static uu_expand::options::TABS

source ·
pub static TABS: &str
\ No newline at end of file diff --git a/dev/uu_false/fn.uu_app.html b/dev/uu_false/fn.uu_app.html index a3fb2e6ff..57aef3d6c 100644 --- a/dev/uu_false/fn.uu_app.html +++ b/dev/uu_false/fn.uu_app.html @@ -1 +1 @@ -uu_app in uu_false - Rust

Function uu_false::uu_app

source ·
pub fn uu_app() -> Command
\ No newline at end of file +uu_app in uu_false - Rust

Function uu_false::uu_app

source ·
pub fn uu_app() -> Command
\ No newline at end of file diff --git a/dev/uu_false/fn.uumain.html b/dev/uu_false/fn.uumain.html index 414151201..94134d624 100644 --- a/dev/uu_false/fn.uumain.html +++ b/dev/uu_false/fn.uumain.html @@ -1 +1 @@ -uumain in uu_false - Rust

Function uu_false::uumain

source ·
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file +uumain in uu_false - Rust

Function uu_false::uumain

source ·
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file diff --git a/dev/uu_false/index.html b/dev/uu_false/index.html index c67b027d9..4944e31a6 100644 --- a/dev/uu_false/index.html +++ b/dev/uu_false/index.html @@ -1 +1 @@ -uu_false - Rust
\ No newline at end of file +uu_false - Rust
\ No newline at end of file diff --git a/dev/uu_groups/fn.uu_app.html b/dev/uu_groups/fn.uu_app.html index dfd042f7d..d7d81e4c1 100644 --- a/dev/uu_groups/fn.uu_app.html +++ b/dev/uu_groups/fn.uu_app.html @@ -1 +1 @@ -uu_app in uu_groups - Rust

Function uu_groups::uu_app

source ·
pub fn uu_app() -> Command
\ No newline at end of file +uu_app in uu_groups - Rust

Function uu_groups::uu_app

source ·
pub fn uu_app() -> Command
\ No newline at end of file diff --git a/dev/uu_groups/fn.uumain.html b/dev/uu_groups/fn.uumain.html index e65d64fd1..d4c85ff50 100644 --- a/dev/uu_groups/fn.uumain.html +++ b/dev/uu_groups/fn.uumain.html @@ -1 +1 @@ -uumain in uu_groups - Rust

Function uu_groups::uumain

source ·
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file +uumain in uu_groups - Rust

Function uu_groups::uumain

source ·
pub fn uumain(args: impl Args) -> i32
\ No newline at end of file diff --git a/dev/uu_groups/index.html b/dev/uu_groups/index.html index cda07c4b9..6641af914 100644 --- a/dev/uu_groups/index.html +++ b/dev/uu_groups/index.html @@ -1 +1 @@ -uu_groups - Rust
\ No newline at end of file +uu_groups - Rust
\ No newline at end of file