wekan_cli/commands/
boards.rs1mod count;
2mod create;
3mod delete;
4mod get;
5mod labels;
6mod list;
7mod members;
8mod rename;
9
10#[cfg(test)]
11mod tests;
12
13use clap::{Args, Subcommand};
14
15use crate::{
16 client::WekanClientFactory, command_result::CommandSuccess, credentials::CredentialStore,
17 error::AppError, input::ConfirmationProvider,
18};
19
20#[derive(Debug, Args)]
21pub struct BoardArgs {
22 #[command(subcommand)]
23 pub command: BoardCommand,
24}
25
26#[derive(Debug, Subcommand)]
27pub enum BoardCommand {
28 Label(labels::LabelArgs),
30 Member(members::MemberArgs),
32 List(list::ListArgs),
34
35 Count(count::CountArgs),
37
38 Get(get::GetArgs),
40
41 Create(create::CreateArgs),
43
44 Rename(rename::RenameArgs),
46
47 Delete(delete::DeleteArgs),
49}
50
51pub(crate) async fn dispatch(
52 command: BoardCommand,
53 client_factory: &WekanClientFactory,
54 credential_store: &dyn CredentialStore,
55 confirmation: &dyn ConfirmationProvider,
56) -> Result<CommandSuccess, AppError> {
57 match command {
58 BoardCommand::Label(args) => {
59 labels::dispatch(args.command, client_factory, credential_store).await
60 }
61 BoardCommand::Member(args) => {
62 members::dispatch(args.command, client_factory, credential_store).await
63 }
64 BoardCommand::List(args) => list::execute(args, client_factory, credential_store).await,
65 BoardCommand::Count(args) => count::execute(args, client_factory, credential_store).await,
66 BoardCommand::Get(args) => get::execute(args, client_factory, credential_store).await,
67 BoardCommand::Create(args) => create::execute(args, client_factory, credential_store).await,
68 BoardCommand::Rename(args) => rename::execute(args, client_factory, credential_store).await,
69 BoardCommand::Delete(args) => {
70 delete::execute(args, client_factory, credential_store, confirmation).await
71 }
72 }
73}
74
75fn non_empty(value: &str) -> Result<String, String> {
76 if value.is_empty() {
77 Err("value must not be empty".to_owned())
78 } else {
79 Ok(value.to_owned())
80 }
81}
82
83fn trimmed_non_empty(value: &str) -> Result<String, String> {
84 let value = value.trim();
85 if value.is_empty() {
86 Err("value must not be empty or whitespace".to_owned())
87 } else {
88 Ok(value.to_owned())
89 }
90}