From fcdb7e48ed51ccaf944c087bc1b6b25bd7322e3d Mon Sep 17 00:00:00 2001 From: shaoyuteng Date: Fri, 10 Mar 2023 20:44:28 +0800 Subject: [PATCH 1/3] relpath: move help strings to markdown file --- src/uu/relpath/relpath.md | 8 ++++++++ src/uu/relpath/src/relpath.rs | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 src/uu/relpath/relpath.md diff --git a/src/uu/relpath/relpath.md b/src/uu/relpath/relpath.md new file mode 100644 index 000000000..a1ff9bf4a --- /dev/null +++ b/src/uu/relpath/relpath.md @@ -0,0 +1,8 @@ +# relpath + +``` +relpath [-d DIR] TO [FROM] +``` + +Convert TO destination to the relative path from the FROM dir. +If FROM path is omitted, current working dir will be used. \ No newline at end of file diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index 522cc54e5..d25956fc1 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -14,10 +14,10 @@ use uucore::display::println_verbatim; use uucore::error::{FromIo, UResult}; use uucore::format_usage; use uucore::fs::{canonicalize, MissingHandling, ResolveMode}; +use uucore::{help_about, help_usage}; -static ABOUT: &str = "Convert TO destination to the relative path from the FROM dir. -If FROM path is omitted, current working dir will be used."; -const USAGE: &str = "{} [-d DIR] TO [FROM]"; +const USAGE: &str = help_usage!("relpath.md"); +const ABOUT: &str = help_about!("relpath.md"); mod options { pub const DIR: &str = "DIR"; From 27150a970bc2e997b5354300f45726bba65c0e83 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 12 Mar 2023 10:58:29 +0100 Subject: [PATCH 2/3] Merge the use declarations --- src/uu/relpath/src/relpath.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index d25956fc1..2b4706a81 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -12,9 +12,8 @@ use std::env; use std::path::{Path, PathBuf}; use uucore::display::println_verbatim; use uucore::error::{FromIo, UResult}; -use uucore::format_usage; +use uucore::{format_usage, help_about, help_usage}; use uucore::fs::{canonicalize, MissingHandling, ResolveMode}; -use uucore::{help_about, help_usage}; const USAGE: &str = help_usage!("relpath.md"); const ABOUT: &str = help_about!("relpath.md"); From 0d03c48f6b9f7fd89b2227ef54d627ae8f6c874a Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 12 Mar 2023 11:11:50 +0100 Subject: [PATCH 3/3] Move the declaration at the right place --- src/uu/relpath/src/relpath.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uu/relpath/src/relpath.rs b/src/uu/relpath/src/relpath.rs index 2b4706a81..ef7c43474 100644 --- a/src/uu/relpath/src/relpath.rs +++ b/src/uu/relpath/src/relpath.rs @@ -12,8 +12,8 @@ use std::env; use std::path::{Path, PathBuf}; use uucore::display::println_verbatim; use uucore::error::{FromIo, UResult}; -use uucore::{format_usage, help_about, help_usage}; use uucore::fs::{canonicalize, MissingHandling, ResolveMode}; +use uucore::{format_usage, help_about, help_usage}; const USAGE: &str = help_usage!("relpath.md"); const ABOUT: &str = help_about!("relpath.md");