From 0768c63361f1c0ea3edaa569cd1f1d7619891453 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 14:30:17 +0100 Subject: [PATCH 1/3] mv: move help strings to markdown file --- src/uu/mv/mv.md | 10 ++++++++++ src/uu/mv/src/mv.rs | 9 +++------ 2 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 src/uu/mv/mv.md diff --git a/src/uu/mv/mv.md b/src/uu/mv/mv.md new file mode 100644 index 000000000..a6cc904f4 --- /dev/null +++ b/src/uu/mv/mv.md @@ -0,0 +1,10 @@ +# mv + +``` + +mv [OPTION]... [-T] SOURCE DEST +mv [OPTION]... SOURCE... DIRECTORY +mv [OPTION]... -t DIRECTORY SOURCE... +``` + +Move `SOURCE` to `DEST`, or multiple `SOURCE`(s) to `DIRECTORY`. diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 0a1394594..ff2601d84 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -25,7 +25,7 @@ use std::path::{Path, PathBuf}; use uucore::backup_control::{self, BackupMode}; use uucore::display::Quotable; use uucore::error::{FromIo, UError, UResult, USimpleError, UUsageError}; -use uucore::{format_usage, prompt_yes, show}; +use uucore::{format_usage, help_about, help_usage, prompt_yes, show}; use fs_extra::dir::{ get_size as dir_get_size, move_dir, move_dir_with_progress, CopyOptions as DirCopyOptions, @@ -53,12 +53,9 @@ pub enum OverwriteMode { Force, } -static ABOUT: &str = "Move SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY."; +static ABOUT: &str = help_about!("mv.md"); static LONG_HELP: &str = ""; -const USAGE: &str = "\ - {} [OPTION]... [-T] SOURCE DEST - {} [OPTION]... SOURCE... DIRECTORY - {} [OPTION]... -t DIRECTORY SOURCE..."; +const USAGE: &str = help_usage!("mv.md"); static OPT_FORCE: &str = "force"; static OPT_INTERACTIVE: &str = "interactive"; From 04c0b5118d37bf583c82a0d918e9c627d81521c8 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 16:06:10 +0100 Subject: [PATCH 2/3] mv: remove long help, change static to const, remove whitespace --- src/uu/mv/mv.md | 1 - src/uu/mv/src/mv.rs | 10 ++-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/uu/mv/mv.md b/src/uu/mv/mv.md index a6cc904f4..772e4bfaf 100644 --- a/src/uu/mv/mv.md +++ b/src/uu/mv/mv.md @@ -1,7 +1,6 @@ # mv ``` - mv [OPTION]... [-T] SOURCE DEST mv [OPTION]... SOURCE... DIRECTORY mv [OPTION]... -t DIRECTORY SOURCE... diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index ff2601d84..4560bf2c3 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -53,8 +53,7 @@ pub enum OverwriteMode { Force, } -static ABOUT: &str = help_about!("mv.md"); -static LONG_HELP: &str = ""; +const ABOUT: &str = help_about!("mv.md"); const USAGE: &str = help_usage!("mv.md"); static OPT_FORCE: &str = "force"; @@ -70,12 +69,7 @@ static ARG_FILES: &str = "files"; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let help = format!( - "{}\n{}", - LONG_HELP, - backup_control::BACKUP_CONTROL_LONG_HELP - ); - let mut app = uu_app().after_help(help); + let mut app = uu_app(); let matches = app.try_get_matches_from_mut(args)?; if !matches.contains_id(OPT_TARGET_DIRECTORY) From ac01925583a932765d49650bcb642ab3776864c4 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski Date: Thu, 23 Mar 2023 16:12:55 +0100 Subject: [PATCH 3/3] mv: restore backup control long help --- src/uu/mv/src/mv.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 4560bf2c3..d3a6d2ed0 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -69,7 +69,7 @@ static ARG_FILES: &str = "files"; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { - let mut app = uu_app(); + let mut app = uu_app().after_help(backup_control::BACKUP_CONTROL_LONG_HELP); let matches = app.try_get_matches_from_mut(args)?; if !matches.contains_id(OPT_TARGET_DIRECTORY)