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