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