pub mod api;
pub mod attachments;
pub mod auth;
pub(crate) mod authenticated;
pub mod boards;
pub mod cards;
pub mod checklist_items;
pub mod checklists;
pub(crate) mod client_error;
pub mod comments;
pub(crate) mod credential_ops;
pub mod custom_field_items;
pub mod custom_fields;
pub mod dependencies;
pub mod integrations;
pub mod lists;
pub mod profile;
pub mod swimlanes;
mod transfer;
pub mod users;
#[cfg(test)]
mod tests;
use clap::Subcommand;
#[derive(Debug, Subcommand)]
pub enum RootCommand {
Integration(integrations::IntegrationArgs),
Dependency(dependencies::DependencyArgs),
Attachment(attachments::AttachmentArgs),
Api(api::ApiArgs),
Auth(auth::AuthArgs),
Profile(profile::ProfileArgs),
User(users::UserArgs),
Board(boards::BoardArgs),
List(lists::ListArgs),
Card(Box<cards::CardArgs>),
Checklist(checklists::ChecklistArgs),
ChecklistItem(checklist_items::ChecklistItemArgs),
Comment(comments::CommentArgs),
CustomField(custom_fields::CustomFieldArgs),
CustomFieldItem(custom_field_items::CustomFieldItemArgs),
Swimlane(swimlanes::SwimlaneArgs),
}
impl RootCommand {
pub fn supports_raw_output(&self) -> bool {
matches!(self, Self::Api(_))
|| matches!(self, Self::Attachment(args) if args.command.download_destination().is_some_and(|d| d.is_stdout()))
}
pub fn validate_output(
&self,
format: crate::output::OutputFormat,
) -> Result<(), crate::error::AppError> {
if let Self::Attachment(args) = self {
args.command.validate_input()?;
if let Some(destination) = args.command.download_destination() {
destination.validate_output(format)?;
}
}
if format == crate::output::OutputFormat::Raw && !self.supports_raw_output() {
return Err(crate::error::AppError::invalid_input(
"--output raw requires api request or an attachment download with --destination -",
));
}
Ok(())
}
}