wekan_cli/commands/
checklists.rs1mod create;
2mod delete;
3mod get;
4mod list;
5mod update;
6
7use clap::{Args, Subcommand};
8
9use crate::{
10 client::WekanClientFactory, command_result::CommandSuccess, credentials::CredentialStore,
11 error::AppError, input::ConfirmationProvider,
12};
13
14#[derive(Debug, Args)]
15pub struct ChecklistArgs {
16 #[command(subcommand)]
17 pub command: ChecklistCommand,
18}
19
20#[derive(Debug, Subcommand)]
21pub enum ChecklistCommand {
22 List(list::ListArgs),
24
25 Get(get::GetArgs),
27
28 Create(create::CreateArgs),
30
31 Update(update::UpdateArgs),
33
34 Delete(delete::DeleteArgs),
36
37 Item(super::checklist_items::ChecklistItemArgs),
39}
40
41pub(crate) async fn dispatch(
42 command: ChecklistCommand,
43 client_factory: &WekanClientFactory,
44 credential_store: &dyn CredentialStore,
45 confirmation: &dyn ConfirmationProvider,
46) -> Result<CommandSuccess, AppError> {
47 match command {
48 ChecklistCommand::Update(args) => {
49 update::execute(args, client_factory, credential_store).await
50 }
51 ChecklistCommand::List(args) => list::execute(args, client_factory, credential_store).await,
52 ChecklistCommand::Get(args) => get::execute(args, client_factory, credential_store).await,
53 ChecklistCommand::Create(args) => {
54 create::execute(args, client_factory, credential_store).await
55 }
56 ChecklistCommand::Delete(args) => {
57 delete::execute(args, client_factory, credential_store, confirmation).await
58 }
59 ChecklistCommand::Item(args) => {
60 super::checklist_items::dispatch(
61 args.command,
62 client_factory,
63 credential_store,
64 confirmation,
65 )
66 .await
67 }
68 }
69}
70
71fn non_empty(value: &str) -> Result<String, String> {
72 let value = value.trim();
73 if value.is_empty() {
74 Err("value must not be empty or whitespace".to_owned())
75 } else {
76 Ok(value.to_owned())
77 }
78}
79
80#[cfg(test)]
81mod tests;