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