aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/repository_command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/command/repository_command.rs')
-rw-r--r--crates/shirabe/src/command/repository_command.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs
index 31d2de3f..d23e114c 100644
--- a/crates/shirabe/src/command/repository_command.rs
+++ b/crates/shirabe/src/command/repository_command.rs
@@ -50,7 +50,7 @@ impl RepositoryCommand {
command
}
- fn list_repositories(&self, mut repos: IndexMap<String, PhpMixed>) {
+ fn list_repositories(&self, mut repos: IndexMap<String, PhpMixed>) -> anyhow::Result<()> {
let io = self.get_io();
let mut packagist_present = false;
@@ -84,7 +84,7 @@ impl RepositoryCommand {
if repos.is_empty() {
io.write("No repositories configured");
- return;
+ return Ok(());
}
for (key, repo) in &repos {
@@ -111,14 +111,19 @@ impl RepositoryCommand {
.get("type")
.and_then(|v| v.as_string())
.unwrap_or("unknown");
- let url = repo_map
+ let url = match repo_map
.get("url")
.and_then(|v| v.as_string())
.map(|s| s.to_string())
- .unwrap_or_else(|| JsonFile::encode(repo));
+ {
+ Some(url) => url,
+ None => JsonFile::encode(repo)?,
+ };
io.write(&format!("[{}] <info>{}</info> {}", name, r#type, url));
}
}
+
+ Ok(())
}
/// PHP: private function suggestTypeForAdd(): \Closure (a static closure — `this` unused)
@@ -352,7 +357,7 @@ impl Command for RepositoryCommand {
match action.as_str() {
"list" | "ls" | "show" => {
- self.list_repositories(repos);
+ self.list_repositories(repos)?;
Ok(0)
}
"add" => {