1pub mod api;
2pub mod attachments;
3pub mod auth;
4pub(crate) mod authenticated;
5pub mod boards;
6pub mod cards;
7pub mod checklist_items;
8pub mod checklists;
9pub(crate) mod client_error;
10pub mod comments;
11pub(crate) mod credential_ops;
12pub mod custom_field_items;
13pub mod custom_fields;
14pub mod dependencies;
15pub mod lists;
16pub mod profile;
17pub mod swimlanes;
18mod transfer;
19pub mod users;
20
21#[cfg(test)]
22mod tests;
23
24use clap::Subcommand;
25
26#[derive(Debug, Subcommand)]
27pub enum RootCommand {
28 Dependency(dependencies::DependencyArgs),
30 Attachment(attachments::AttachmentArgs),
32 Api(api::ApiArgs),
34
35 Auth(auth::AuthArgs),
37
38 Profile(profile::ProfileArgs),
40
41 User(users::UserArgs),
43
44 Board(boards::BoardArgs),
46
47 List(lists::ListArgs),
49
50 Card(Box<cards::CardArgs>),
52
53 Checklist(checklists::ChecklistArgs),
55
56 ChecklistItem(checklist_items::ChecklistItemArgs),
58
59 Comment(comments::CommentArgs),
61
62 CustomField(custom_fields::CustomFieldArgs),
64
65 CustomFieldItem(custom_field_items::CustomFieldItemArgs),
67
68 Swimlane(swimlanes::SwimlaneArgs),
70}
71
72impl RootCommand {
73 pub fn supports_raw_output(&self) -> bool {
74 matches!(self, Self::Api(_))
75 || matches!(self, Self::Attachment(args) if args.command.download_destination().is_some_and(|d| d.is_stdout()))
76 }
77
78 pub fn validate_output(
79 &self,
80 format: crate::output::OutputFormat,
81 ) -> Result<(), crate::error::AppError> {
82 if let Self::Attachment(args) = self {
83 args.command.validate_input()?;
84 if let Some(destination) = args.command.download_destination() {
85 destination.validate_output(format)?;
86 }
87 }
88 if format == crate::output::OutputFormat::Raw && !self.supports_raw_output() {
89 return Err(crate::error::AppError::invalid_input(
90 "--output raw requires api request or an attachment download with --destination -",
91 ));
92 }
93 Ok(())
94 }
95}