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