wekan_cli/commands/
boards.rs1mod count;
2mod create;
3mod delete;
4mod get;
5mod list;
6mod rename;
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 BoardArgs {
20 #[command(subcommand)]
21 pub command: BoardCommand,
22}
23
24#[derive(Debug, Subcommand)]
25pub enum BoardCommand {
26 List(list::ListArgs),
28
29 Count(count::CountArgs),
31
32 Get(get::GetArgs),
34
35 Create(create::CreateArgs),
37
38 Rename(rename::RenameArgs),
40
41 Delete(delete::DeleteArgs),
43}
44
45pub(crate) async fn dispatch(
46 command: BoardCommand,
47 client_factory: &WekanClientFactory,
48 credential_store: &dyn CredentialStore,
49 confirmation: &dyn ConfirmationProvider,
50) -> Result<CommandSuccess, AppError> {
51 match command {
52 BoardCommand::List(args) => list::execute(args, client_factory, credential_store).await,
53 BoardCommand::Count(args) => count::execute(args, client_factory, credential_store).await,
54 BoardCommand::Get(args) => get::execute(args, client_factory, credential_store).await,
55 BoardCommand::Create(args) => create::execute(args, client_factory, credential_store).await,
56 BoardCommand::Rename(args) => rename::execute(args, client_factory, credential_store).await,
57 BoardCommand::Delete(args) => {
58 delete::execute(args, client_factory, credential_store, confirmation).await
59 }
60 }
61}
62
63fn non_empty(value: &str) -> Result<String, String> {
64 if value.is_empty() {
65 Err("value must not be empty".to_owned())
66 } else {
67 Ok(value.to_owned())
68 }
69}
70
71fn trimmed_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}