Skip to main content

wekan_cli/commands/
system.rs

1use clap::{Args, Subcommand};
2
3use super::client_error::map_client_error;
4use crate::{
5    client::WekanClientFactory, command_result::CommandSuccess, error::AppError,
6    redaction::Redactor,
7};
8
9#[derive(Debug, Args)]
10pub struct SystemArgs {
11    #[command(subcommand)]
12    pub command: SystemCommand,
13}
14
15#[derive(Debug, Subcommand)]
16pub enum SystemCommand {
17    /// Read public startup schema-upgrade status without credentials.
18    SchemaUpgradeStatus,
19}
20
21pub(crate) async fn dispatch(
22    command: SystemCommand,
23    factory: &WekanClientFactory,
24) -> Result<CommandSuccess, AppError> {
25    match command {
26        SystemCommand::SchemaUpgradeStatus => {
27            let state = factory
28                .create()
29                .map_err(AppError::from)?
30                .schema_upgrade_status()
31                .await
32                .map_err(|e| {
33                    map_client_error(e, &Redactor::default(), "schema-upgrade status", false)
34                })?;
35            Ok(CommandSuccess::SchemaUpgradeStatus(state))
36        }
37    }
38}