Skip to main content

wekan_cli/commands/
admin.rs

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