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 Comment(comments::CommentArgs),
67
68 CustomField(custom_fields::CustomFieldArgs),
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}