From 070e912b3ed9b5bef35ff6c9cdb723c1daa2fb04 Mon Sep 17 00:00:00 2001 From: Fintan Halpenny Date: Fri, 8 Dec 2023 14:19:53 +0000 Subject: [PATCH] cli: allow directory in rad clone Allow the user to specify a directory to clone into when performing `rad clone`. Signed-off-by: Fintan Halpenny X-Clacks-Overhead: GNU Terry Pratchett --- radicle-cli/examples/rad-clone-directory.md | 27 ++++++++++++++ radicle-cli/src/commands/clone.rs | 40 ++++++++++++++++++--- radicle-cli/tests/commands.rs | 26 ++++++++++++++ 3 files changed, 88 insertions(+), 5 deletions(-) create mode 100644 radicle-cli/examples/rad-clone-directory.md diff --git a/radicle-cli/examples/rad-clone-directory.md b/radicle-cli/examples/rad-clone-directory.md new file mode 100644 index 00000000..2202feec --- /dev/null +++ b/radicle-cli/examples/rad-clone-directory.md @@ -0,0 +1,27 @@ +We can specify where a repository gets cloned into on our filesystem +by specifying the directory in the `rad clone` command: + +``` +$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --scope followed Developer/Radicle +✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'followed' +✓ Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from z6MknSL…StBU8Vi.. +✓ Creating checkout in ./Developer/Radicle.. +✓ Remote alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi added +✓ Remote-tracking branch alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master created for z6MknSL…StBU8Vi +✓ Repository successfully cloned under [..]/Developer/Radicle/ +╭────────────────────────────────────╮ +│ heartwood │ +│ Radicle Heartwood Protocol & Stack │ +│ 0 issues · 0 patches │ +╰────────────────────────────────────╯ +Run `cd [..]/Developer/Radicle` to go to the project directory. +``` + +Note that attempting to clone into a directory that already exists, +and is not empty, will fail: + +``` (fail) +$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji --scope followed Developer/Radicle +✓ Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from z6MknSL…StBU8Vi.. +✗ Error: the directory path "Developer/Radicle" already exists +``` diff --git a/radicle-cli/src/commands/clone.rs b/radicle-cli/src/commands/clone.rs index 35c807d6..592069a2 100644 --- a/radicle-cli/src/commands/clone.rs +++ b/radicle-cli/src/commands/clone.rs @@ -1,6 +1,6 @@ #![allow(clippy::or_fun_call)] use std::ffi::OsString; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::str::FromStr; use std::time; @@ -34,7 +34,7 @@ pub const HELP: Help = Help { usage: r#" Usage - rad clone [--scope ] [