pub mod html;
pub mod json;
pub mod text;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum OutputFormat {
Text {
tree: bool,
summary_only: bool,
quiet: bool,
hyperlinks: bool,
},
Json {
tree: bool,
summary_only: bool,
},
Html {
tree: bool,
summary_only: bool,
},
}
impl Default for OutputFormat {
fn default() -> Self {
OutputFormat::Text {
tree: false,
summary_only: false,
quiet: false,
hyperlinks: true,
}
}
}
impl OutputFormat {
pub fn text(tree: bool, summary_only: bool, quiet: bool, hyperlinks: bool) -> Self {
OutputFormat::Text {
tree,
summary_only,
quiet,
hyperlinks,
}
}
pub fn json(tree: bool, summary_only: bool) -> Self {
OutputFormat::Json { tree, summary_only }
}
pub fn html(tree: bool, summary_only: bool) -> Self {
OutputFormat::Html { tree, summary_only }
}
pub fn quiet() -> Self {
OutputFormat::Text {
tree: false,
summary_only: false,
quiet: true,
hyperlinks: false,
}
}
pub fn is_json(&self) -> bool {
matches!(self, OutputFormat::Json { .. })
}
pub fn is_html(&self) -> bool {
matches!(self, OutputFormat::Html { .. })
}
pub fn is_text(&self) -> bool {
matches!(self, OutputFormat::Text { .. })
}
pub fn show_progress(&self) -> bool {
match self {
OutputFormat::Text {
quiet,
summary_only,
..
} => !quiet && !summary_only,
OutputFormat::Json { .. } | OutputFormat::Html { .. } => false,
}
}
pub fn is_summary_only(&self) -> bool {
match self {
OutputFormat::Text { summary_only, .. }
| OutputFormat::Json { summary_only, .. }
| OutputFormat::Html { summary_only, .. } => *summary_only,
}
}
pub fn show_tree(&self) -> bool {
match self {
OutputFormat::Text { tree, .. }
| OutputFormat::Json { tree, .. }
| OutputFormat::Html { tree, .. } => *tree,
}
}
pub fn use_hyperlinks(&self) -> bool {
match self {
OutputFormat::Text { hyperlinks, .. } => *hyperlinks,
OutputFormat::Json { .. } | OutputFormat::Html { .. } => false,
}
}
}