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;
18pub mod users;
19
20use clap::Subcommand;
21
22#[derive(Debug, Subcommand)]
23pub enum RootCommand {
24 Dependency(dependencies::DependencyArgs),
26 Attachment(attachments::AttachmentArgs),
28 Api(api::ApiArgs),
30
31 Auth(auth::AuthArgs),
33
34 Profile(profile::ProfileArgs),
36
37 User(users::UserArgs),
39
40 Board(boards::BoardArgs),
42
43 List(lists::ListArgs),
45
46 Card(Box<cards::CardArgs>),
48
49 Checklist(checklists::ChecklistArgs),
51
52 ChecklistItem(checklist_items::ChecklistItemArgs),
54
55 Comment(comments::CommentArgs),
57
58 CustomField(custom_fields::CustomFieldArgs),
60
61 CustomFieldItem(custom_field_items::CustomFieldItemArgs),
63
64 Swimlane(swimlanes::SwimlaneArgs),
66}
67
68impl RootCommand {
69 pub fn supports_raw_output(&self) -> bool {
70 matches!(self, Self::Api(_))
71 || matches!(self, Self::Attachment(args) if args.command.download_destination().is_some_and(|d| d.is_stdout()))
72 }
73
74 pub fn validate_output(
75 &self,
76 format: crate::output::OutputFormat,
77 ) -> Result<(), crate::error::AppError> {
78 if let Self::Attachment(args) = self {
79 args.command.validate_input()?;
80 if let Some(destination) = args.command.download_destination() {
81 destination.validate_output(format)?;
82 }
83 }
84 if format == crate::output::OutputFormat::Raw && !self.supports_raw_output() {
85 return Err(crate::error::AppError::invalid_input(
86 "--output raw requires api request or an attachment download with --destination -",
87 ));
88 }
89 Ok(())
90 }
91}