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