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