grp_core/common/orgs/
create.rs1use crate::error::types::ErrorType;
2use crate::platform::Platform;
3use crate::error::structs::Error;
4use crate::config::Config;
5use crate::common::users::structs::User;
6use crate::animation::Animation;
7use crate::specific::{gitea, gitlab};
8
9
10impl Platform {
11 pub async fn create_org<T: Into<String>, A: Animation + ?Sized>(&self,
23 name: T,
24 config: &Config,
25 recursive: bool,
26 animation: &Box<A>
27 ) -> (Vec<User>, Vec<Error>) {
28 let name = name.into();
29 match self {
30 Platform::Github => (
31 vec![],
32 vec![Error::new(
33 ErrorType::Unsupported,
34 vec![self.name(), "Create Orgs"]
35 )]
36 ),
37 Platform::Codeberg |
38 Platform::Forgejo |
39 Platform::Gitea => {
40 let result = gitea::orgs::create::create(self, &name, config, animation).await;
41 match result {
42 Ok(u) => (vec![u], vec![]),
43 Err(e) => (vec![], vec![e]),
44 }
45 },
46 Platform::Gitlab => gitlab::groups::create::create_group(self, &name, &config, recursive, animation).await
47 }
48 }
49}