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