wekan_cli/commands/
checklists.rs1mod create;
2mod delete;
3mod get;
4mod list;
5
6use clap::{Args, Subcommand};
7
8use crate::{
9 client::WekanClientFactory, command_result::CommandSuccess, credentials::CredentialStore,
10 error::AppError, input::ConfirmationProvider,
11};
12
13#[derive(Debug, Args)]
14pub struct ChecklistArgs {
15 #[command(subcommand)]
16 pub command: ChecklistCommand,
17}
18
19#[derive(Debug, Subcommand)]
20pub enum ChecklistCommand {
21 List(list::ListArgs),
23
24 Get(get::GetArgs),
26
27 Create(create::CreateArgs),
29
30 Delete(delete::DeleteArgs),
32}
33
34pub(crate) async fn dispatch(
35 command: ChecklistCommand,
36 client_factory: &WekanClientFactory,
37 credential_store: &dyn CredentialStore,
38 confirmation: &dyn ConfirmationProvider,
39) -> Result<CommandSuccess, AppError> {
40 match command {
41 ChecklistCommand::List(args) => list::execute(args, client_factory, credential_store).await,
42 ChecklistCommand::Get(args) => get::execute(args, client_factory, credential_store).await,
43 ChecklistCommand::Create(args) => {
44 create::execute(args, client_factory, credential_store).await
45 }
46 ChecklistCommand::Delete(args) => {
47 delete::execute(args, client_factory, credential_store, confirmation).await
48 }
49 }
50}
51
52fn non_empty(value: &str) -> Result<String, String> {
53 let value = value.trim();
54 if value.is_empty() {
55 Err("value must not be empty or whitespace".to_owned())
56 } else {
57 Ok(value.to_owned())
58 }
59}
60
61#[cfg(test)]
62mod tests;