1use anyhow::Result;
2mod client;
5use client::*;
6pub mod cli;
7use cli::{FollowupArgs, PrArgs};
8mod render;
9mod table;
10mod types;
11
12pub async fn pr(options: &PrArgs, github_api_token: &str) -> Result<Vec<types::ScoredPr>> {
13 let username = get_username(&options.user, github_api_token).await;
14
15 fetch_scored_prs(github_api_token, &username, options).await
16}
17
18pub async fn pr_render(options: &PrArgs, github_api_token: &str) -> Result<String> {
19 let sprs: Vec<types::ScoredPr> = pr(options, github_api_token).await?;
20
21 Ok(render::prs(
22 &sorted_ranked_prs(sprs),
23 options.num,
24 options.debug,
25 options.short,
26 options.json,
27 ))
28}
29
30pub async fn followup(options: &FollowupArgs, github_api_token: &str) -> Vec<types::Review> {
31 let username = get_username(&options.user, github_api_token).await;
32
33 followup::followup(github_api_token, &username).await
34}
35
36pub async fn followup_render(options: &FollowupArgs, github_api_token: &str) -> String {
37 let reviews = followup(options, github_api_token).await;
38
39 render::reviews(&reviews, options.json)
40}
41
42pub async fn get_username(user: &Option<String>, github_api_token: &str) -> String {
43 match user {
44 Some(username) => username.to_string(),
45 None => username::username(github_api_token).await,
46 }
47}
48
49