cli: Don't panic if operation is interrupted
We handle the errors correctly and return.
This commit is contained in:
parent
1ab1da1ba1
commit
16d49c0b82
|
|
@ -214,30 +214,30 @@ pub fn init(options: Options, profile: &profile::Profile) -> anyhow::Result<()>
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
|
||||||
let name = options.name.unwrap_or_else(|| {
|
let name = match options.name {
|
||||||
let default = path.file_name().map(|f| f.to_string_lossy().to_string());
|
Some(name) => name,
|
||||||
term::input(
|
None => {
|
||||||
"Name",
|
let default = path.file_name().map(|f| f.to_string_lossy().to_string());
|
||||||
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() {
|
|
||||||
term::input(
|
term::input(
|
||||||
"Default branch",
|
"Name",
|
||||||
Some(head),
|
default,
|
||||||
Some("Please specify an existing branch"),
|
Some("The name of your repository, eg. 'acme'"),
|
||||||
)
|
)?
|
||||||
.unwrap()
|
|
||||||
} else {
|
|
||||||
head
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
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())
|
let branch = RefString::try_from(branch.clone())
|
||||||
.map_err(|e| anyhow!("invalid branch name {:?}: {}", branch, e))?;
|
.map_err(|e| anyhow!("invalid branch name {:?}: {}", branch, e))?;
|
||||||
let visibility = if let Some(v) = options.visibility {
|
let visibility = if let Some(v) = options.visibility {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue