summaryrefslogtreecommitdiffstats
path: root/src/commands/source.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-11-11 12:32:22 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-11-11 17:05:26 +0100
commit11dcefb5fe5b2a0004a28209332045462c8127a1 (patch)
tree99cb4d46242f4bd9675cd79228df28c272781f06 /src/commands/source.rs
parent7efc168d0a96546a37a7d079b23eed81e2fcf60e (diff)
Add "source url" subcommand
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/commands/source.rs')
-rw-r--r--src/commands/source.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/commands/source.rs b/src/commands/source.rs
index 474f524..25efcce 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -15,6 +15,7 @@ pub async fn source<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo:
match matches.subcommand() {
("verify", Some(matches)) => verify(matches, config, repo).await,
("list-missing", Some(matches)) => list_missing(matches, config, repo).await,
+ ("url", Some(matches)) => url(matches, config, repo).await,
(other, _) => return Err(anyhow!("Unknown subcommand: {}", other)),
}
}
@@ -67,3 +68,15 @@ pub async fn list_missing<'a>(_: &ArgMatches, config: &Configuration<'a>, repo:
.collect()
}
+pub async fn url<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> {
+ let out = std::io::stdout();
+ let mut outlock = out.lock();
+
+ let pname = matches.value_of("package_name").map(String::from).map(PackageName::from);
+
+ repo.packages()
+ .filter(|p| pname.as_ref().map(|n| p.name() == n).unwrap_or(true))
+ .map(|p| writeln!(outlock, "{} {} -> {}", p.name(), p.version(), p.source().url()).map_err(Error::from))
+ .collect()
+}
+