diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-11-11 12:25:04 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-11-11 17:05:26 +0100 |
commit | 4aab9807357d6e522f2a979af82ea8fafbce027f (patch) | |
tree | bd65b454e8c3d3f8d123a6ae09285e3bd45f665f /src | |
parent | 7af96e33717573c1acbbcd4146b65ef73ce33cc9 (diff) |
Move to have "source" subcommand
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/cli.rs | 19 | ||||
-rw-r--r-- | src/commands/mod.rs | 4 | ||||
-rw-r--r-- | src/commands/source.rs (renamed from src/commands/verify_sources.rs) | 11 | ||||
-rw-r--r-- | src/main.rs | 4 |
4 files changed, 24 insertions, 14 deletions
@@ -278,14 +278,17 @@ pub fn cli<'a>() -> App<'a> { .help("Do not use the fancy format, but simply <name> <version>") ) ) - .subcommand(App::new("verify-sources") - .about("Hash-check all source files") - .arg(Arg::with_name("package_name") - .required(false) - .multiple(false) - .index(1) - .value_name("PKG") - .help("Verify the sources of this package (optional, if left out, all packages are checked)") + .subcommand(App::new("source") + .about("Handle package sources") + .subcommand(App::new("verify") + .about("Hash-check all source files") + .arg(Arg::with_name("package_name") + .required(false) + .multiple(false) + .index(1) + .value_name("PKG") + .help("Verify the sources of this package (optional, if left out, all packages are checked)") + ) ) ) diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 6c8c0db..6dbd7ae 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -16,8 +16,8 @@ pub use dependencies_of::dependencies_of; mod what_depends; pub use what_depends::what_depends; -mod verify_sources; -pub use verify_sources::verify_sources; +mod source; +pub use source::source; mod versions_of; pub use versions_of::versions_of; diff --git a/src/commands/verify_sources.rs b/src/commands/source.rs index 3f7b9c8..9cb1f48 100644 --- a/src/commands/verify_sources.rs +++ b/src/commands/source.rs @@ -2,6 +2,7 @@ use std::io::Write; use std::path::PathBuf; use anyhow::Result; +use anyhow::anyhow; use clap_v3::ArgMatches; use crate::config::*; @@ -9,7 +10,14 @@ use crate::package::PackageName; use crate::repository::Repository; use crate::source::*; -pub async fn verify_sources<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> { +pub async fn source<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> { + match matches.subcommand() { + ("verify", Some(matches)) => verify(matches, config, repo).await, + (other, _) => return Err(anyhow!("Unknown subcommand: {}", other)), + } +} + +pub async fn verify<'a>(matches: &ArgMatches, config: &Configuration<'a>, repo: Repository) -> Result<()> { use tokio::stream::StreamExt; let source_cache_root = PathBuf::from(config.source_cache_root()); @@ -39,4 +47,3 @@ pub async fn verify_sources<'a>(matches: &ArgMatches, config: &Configuration<'a> .collect::<Result<()>>() .await } - diff --git a/src/main.rs b/src/main.rs index cef9b43..0940356 100644 --- a/src/main.rs +++ b/src/main.rs @@ -100,9 +100,9 @@ async fn main() -> Result<()> { crate::commands::find_pkg(matches, &config, repo).await? }, - ("verify-sources", Some(matches)) => { + ("source", Some(matches)) => { let repo = load_repo()?; - crate::commands::verify_sources(matches, &config, repo).await? + crate::commands::source(matches, &config, repo).await? } (other, _) => return Err(anyhow!("Unknown subcommand: {}", other)), |