Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Don't panic if operation is interrupted
cloudhead committed 2 years ago
commit 16d49c0b821746bb6034d6d78c8ba1ea01b3a114
parent 1ab1da1ba196ec3fd7ed6b15198f4b4093bb4e6c
1 file changed +22 -22
modified radicle-cli/src/commands/init.rs
@@ -214,30 +214,30 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
        }
    ));

-
    let name = options.name.unwrap_or_else(|| {
-
        let default = path.file_name().map(|f| f.to_string_lossy().to_string());
-
        term::input(
-
            "Name",
-
            default,
-
            Some("The name of your repository, eg. 'acme'"),
-
        )
-
        .unwrap()
-
    });
-
    let description = options.description.unwrap_or_else(|| {
-
        term::input("Description", None, Some("You may leave this blank")).unwrap()
-
    });
-
    let branch = options.branch.unwrap_or_else(|| {
-
        if interactive.yes() {
+
    let name = match options.name {
+
        Some(name) => name,
+
        None => {
+
            let default = path.file_name().map(|f| f.to_string_lossy().to_string());
            term::input(
-
                "Default branch",
-
                Some(head),
-
                Some("Please specify an existing branch"),
-
            )
-
            .unwrap()
-
        } else {
-
            head
+
                "Name",
+
                default,
+
                Some("The name of your repository, eg. 'acme'"),
+
            )?
        }
-
    });
+
    };
+
    let description = match options.description {
+
        Some(desc) => desc,
+
        None => term::input("Description", None, Some("You may leave this blank"))?,
+
    };
+
    let branch = match options.branch {
+
        Some(branch) => branch,
+
        None if interactive.yes() => term::input(
+
            "Default branch",
+
            Some(head),
+
            Some("Please specify an existing branch"),
+
        )?,
+
        None => head,
+
    };
    let branch = RefString::try_from(branch.clone())
        .map_err(|e| anyhow!("invalid branch name {:?}: {}", branch, e))?;
    let visibility = if let Some(v) = options.visibility {