mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-10 12:09:33 +01:00
Merge pull request 'improve look of issues' (#84) from issue-pr-parity into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/84
This commit is contained in:
commit
883a20129a
1 changed files with 44 additions and 4 deletions
|
@ -236,7 +236,26 @@ async fn create_issue(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn view_issue(repo: &RepoName, api: &Forgejo, id: u64) -> eyre::Result<()> {
|
pub async fn view_issue(repo: &RepoName, api: &Forgejo, id: u64) -> eyre::Result<()> {
|
||||||
|
let crate::SpecialRender {
|
||||||
|
dash,
|
||||||
|
|
||||||
|
bright_red,
|
||||||
|
bright_green,
|
||||||
|
yellow,
|
||||||
|
dark_grey,
|
||||||
|
white,
|
||||||
|
reset,
|
||||||
|
..
|
||||||
|
} = crate::special_render();
|
||||||
|
|
||||||
let issue = api.issue_get_issue(repo.owner(), repo.name(), id).await?;
|
let issue = api.issue_get_issue(repo.owner(), repo.name(), id).await?;
|
||||||
|
|
||||||
|
// if it's a pull request, display it as one instead
|
||||||
|
if issue.pull_request.is_some() {
|
||||||
|
crate::prs::view_pr(repo, api, Some(id)).await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
let title = issue
|
let title = issue
|
||||||
.title
|
.title
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -249,12 +268,33 @@ pub async fn view_issue(repo: &RepoName, api: &Forgejo, id: u64) -> eyre::Result
|
||||||
.login
|
.login
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.ok_or_else(|| eyre::eyre!("user does not have login"))?;
|
.ok_or_else(|| eyre::eyre!("user does not have login"))?;
|
||||||
println!("#{}: {}", id, title);
|
let state = issue
|
||||||
println!("By {}", username);
|
.state
|
||||||
|
.ok_or_else(|| eyre::eyre!("pr does not have state"))?;
|
||||||
|
let comments = issue.comments.unwrap_or_default();
|
||||||
|
|
||||||
|
println!("{yellow}{title} {dark_grey}#{id}{reset}");
|
||||||
|
print!("By {white}{username}{reset} {dash} ");
|
||||||
|
|
||||||
|
use forgejo_api::structs::StateType;
|
||||||
|
match state {
|
||||||
|
StateType::Open => println!("{bright_green}Open{reset}"),
|
||||||
|
StateType::Closed => println!("{bright_red}Closed{reset}"),
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(body) = &issue.body {
|
if let Some(body) = &issue.body {
|
||||||
|
if !body.is_empty() {
|
||||||
println!();
|
println!();
|
||||||
println!("{}", crate::markdown(body));
|
println!("{}", crate::markdown(body));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
println!();
|
||||||
|
|
||||||
|
if comments == 1 {
|
||||||
|
println!("1 comment");
|
||||||
|
} else {
|
||||||
|
println!("{comments} comments");
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
async fn view_issues(
|
async fn view_issues(
|
||||||
|
|
Loading…
Reference in a new issue