From ce1e1f71ae7554711f4481faed9b66543434d3f7 Mon Sep 17 00:00:00 2001 From: josibake Date: Wed, 21 Feb 2024 16:20:39 +0100 Subject: [PATCH] cli: Improve `rad init` wording If the user passes a argument to init, it is incorrect and a bit confusing to reference the "current directory" or "this directory" e.g. "run rad . in current directory" when the repo was not created in the current directory and was created with a path argument instead. Use the path provided by the user in help text, otherwise reference the current directory. --- radicle-cli/examples/rad-init-no-git.md | 2 +- radicle-cli/src/commands/init.rs | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/radicle-cli/examples/rad-init-no-git.md b/radicle-cli/examples/rad-init-no-git.md index 3b9b8bb0..505c426a 100644 --- a/radicle-cli/examples/rad-init-no-git.md +++ b/radicle-cli/examples/rad-init-no-git.md @@ -3,7 +3,7 @@ it will fail: ``` (fail) $ rad init -✗ Error: a Git repository was not found at the current path +✗ Error: a Git repository was not found at the given path ``` Ok so let's initialize one. diff --git a/radicle-cli/src/commands/init.rs b/radicle-cli/src/commands/init.rs index 0a996777..71fcf0da 100644 --- a/radicle-cli/src/commands/init.rs +++ b/radicle-cli/src/commands/init.rs @@ -196,7 +196,7 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()> let repo = match git::Repository::open(&path) { Ok(r) => r, Err(e) if radicle::git::ext::is_not_found_err(&e) => { - anyhow::bail!("a Git repository was not found at the current path") + anyhow::bail!("a Git repository was not found at the given path") } Err(e) => return Err(e.into()), }; @@ -316,8 +316,13 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()> term::format::dim("(RID)"), term::format::highlight(rid.urn()) ); + let directory = if path == cwd { + "this directory".to_owned() + } else { + term::format::tertiary(path.display()).to_string() + }; term::info!( - "You can show it any time by running {} from this directory.", + "You can show it any time by running {} from {directory}.", term::format::command("rad .") ); term::blank();