blob: e0455ca690c6e9ba0dabfe43c8a76707dc351b5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
use anyhow::anyhow;
use anyhow::Result;
use clap::ArgMatches;
use result_inspect::*;
use librepology::v1::api::*;
use librepology::v1::types::response::Problem;
use librepology::endpoint::DefaultEndpoint;
mod cli;
#[tokio::main]
async fn main() -> Result<()> {
let _ = env_logger::try_init()?;
let app = cli::app();
match app.get_matches().subcommand() {
("problems", Some(mtch)) => problems(mtch).await,
(other, _) => Err(anyhow!("No such subcommand: {}", other)),
}
}
async fn problems<'a>(matches: &ArgMatches<'a>) -> Result<()> {
let repo = matches.value_of("repo").map(String::from).unwrap(); // safe by clap
let client = ApiClient::new::<DefaultEndpoint>()?;
client.problems()
.for_repo(repo)
.to_request()
.perform()
.await
.inspect(|response| log::debug!("Response: {:?}", response))?
.into_iter()
.for_each(|problem| {
println!("Problem: {:?}", problem);
});
Ok(())
}
|