codeberg_cli/actions/pull_request/
mod.rs1use crate::render::option::option_display;
2
3pub mod comment;
4pub mod create;
5pub mod edit;
6pub mod list;
7pub mod view;
8
9use clap::Subcommand;
10
11use super::GeneralArgs;
12
13#[derive(Subcommand, Debug)]
15pub enum PullRequestArgs {
16 List(list::ListPullRequestArgs),
17 Create(create::CreatePullRequestArgs),
18 Edit(edit::EditPullRequestArgs),
19 View(view::ViewPullRequestsArgs),
20 Comment(comment::CommentPullRequestArgs),
21}
22
23impl PullRequestArgs {
24 pub async fn run(self, general_args: GeneralArgs) -> anyhow::Result<()> {
25 match self {
26 PullRequestArgs::List(args) => args.run(general_args).await,
27 PullRequestArgs::Create(args) => args.run(general_args).await,
28 PullRequestArgs::Edit(args) => args.run(general_args).await,
29 PullRequestArgs::View(args) => args.run(general_args).await,
30 PullRequestArgs::Comment(args) => args.run(general_args).await,
31 }
32 }
33}
34
35fn display_pull_request(pull_request: &forgejo_api::structs::PullRequest) -> String {
36 let nr = option_display(&pull_request.number);
37 let title = option_display(&pull_request.title);
38 format!("#{nr}:{title}")
39}