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