codeberg_cli/actions/repo/
mod.rs

1pub mod assignees;
2pub mod clone;
3pub mod create;
4pub mod delete;
5pub mod fork;
6pub mod info;
7
8use clap::Subcommand;
9
10use super::GeneralArgs;
11
12/// Repository subcommands
13#[derive(Subcommand, Debug)]
14pub enum RepoArgs {
15    Create(create::RepoCreateArgs),
16    Clone(clone::RepoCloneArgs),
17    Delete(delete::RepoDeleteArgs),
18    Fork(fork::RepoForkArgs),
19    Info(info::RepoInfoArgs),
20    Assignees(assignees::RepoAssigneesArgs),
21}
22
23impl RepoArgs {
24    pub async fn run(self, general_args: GeneralArgs) -> anyhow::Result<()> {
25        match self {
26            RepoArgs::Create(args) => args.run(general_args).await,
27            RepoArgs::Clone(args) => args.run(general_args).await,
28            RepoArgs::Delete(args) => args.run(general_args).await,
29            RepoArgs::Fork(args) => args.run(general_args).await,
30            RepoArgs::Info(args) => args.run(general_args).await,
31            RepoArgs::Assignees(args) => args.run(general_args).await,
32        }
33    }
34}
35
36/// parses a string of format OWNER/REPO
37fn parse_owner_and_repo(owner_and_repo: &str) -> anyhow::Result<(String, String)> {
38    owner_and_repo
39        .split_once('/')
40        .map(|(owner, repo)| (owner.to_owned(), repo.to_owned()))
41        .ok_or_else(|| {
42            anyhow::anyhow!(
43                "Please provide the repository you want to clone in the format OWNER/REPO."
44            )
45        })
46}