Skip to main content

wekan_cli/commands/
admin.rs

1pub mod attachment_settings;
2pub mod domains;
3mod features;
4mod input;
5mod login_providers;
6pub mod organizations;
7mod problems;
8pub mod settings;
9pub mod teams;
10
11use crate::{
12    client::WekanClientFactory,
13    command_result::CommandSuccess,
14    credentials::{CredentialStore, SecretInputProvider},
15    error::AppError,
16    input::ConfirmationProvider,
17};
18use clap::{Args, Subcommand};
19
20#[derive(Debug, Args)]
21pub struct AdminArgs {
22    #[command(subcommand)]
23    pub command: AdminCommand,
24}
25#[derive(Debug, Subcommand)]
26pub enum AdminCommand {
27    /// Inspect and configure OAuth login providers (site admin).
28    OauthProvider(login_providers::OauthProviderArgs),
29    /// Configure email-code sign-in (site admin).
30    Passwordless(login_providers::PasswordlessArgs),
31    /// Inspect and acknowledge administrator problem reports.
32    Problem(problems::ProblemArgs),
33    /// Report primary-email domains and user counts (site admin).
34    Domain(domains::DomainArgs),
35    /// List organizations and configure their feature flags (site admin).
36    Org(organizations::OrganizationArgs),
37    /// List teams and configure their feature flags (site admin).
38    Team(teams::TeamArgs),
39    /// Read or update the global REST settings allowlist (site admin).
40    Settings(settings::SettingsArgs),
41    /// Configure attachment backends, restrictions, and migration settings (site admin).
42    AttachmentSettings(attachment_settings::AttachmentSettingsArgs),
43}
44pub(crate) async fn dispatch(
45    command: AdminCommand,
46    factory: &WekanClientFactory,
47    store: &dyn CredentialStore,
48    secrets: &dyn SecretInputProvider,
49    confirmation: &dyn ConfirmationProvider,
50) -> Result<CommandSuccess, AppError> {
51    match command {
52        AdminCommand::OauthProvider(args) => {
53            login_providers::oauth(args.command, factory, store, secrets).await
54        }
55        AdminCommand::Passwordless(args) => {
56            login_providers::passwordless(args.command, factory, store).await
57        }
58        AdminCommand::Problem(args) => problems::execute(args.command, factory, store).await,
59        AdminCommand::Domain(args) => domains::execute(args.command, factory, store).await,
60        AdminCommand::Org(args) => {
61            organizations::execute(args.command, factory, store, confirmation).await
62        }
63        AdminCommand::Team(args) => {
64            teams::execute(args.command, factory, store, confirmation).await
65        }
66        AdminCommand::Settings(args) => settings::execute(args.command, factory, store).await,
67        AdminCommand::AttachmentSettings(args) => {
68            attachment_settings::execute(args.command, factory, store, secrets).await
69        }
70    }
71}