1pub mod changelog_extractor;
2pub mod json_printer;
3pub mod macros;
4pub mod table_printer;
5
6use jira_v3_openapi::models::{
7 CreatedIssue, FieldCreateMetadata, IssueBean, IssueTransition, IssueTypeIssueCreateMetadata,
8 Project, Version,
9};
10use serde::Serialize;
11use serde_json::Value;
12
13use crate::args::commands::{OutputTypes, OutputValues};
14
15#[derive(Serialize)]
24pub enum PrintableData {
25 Generic {
26 data: Vec<Value>,
27 },
28 IssueCreated {
29 issues: Vec<CreatedIssue>,
30 },
31 IssueData {
32 issues: Vec<IssueBean>,
33 },
34 IssueTransitions {
35 transitions: Vec<IssueTransition>,
36 },
37 IssueType {
38 issue_types: Vec<IssueTypeIssueCreateMetadata>,
39 },
40 IssueTypeField {
41 issue_type_fields: Vec<FieldCreateMetadata>,
42 },
43 Project {
44 projects: Vec<Project>,
45 },
46 TransitionedIssue {
47 issues: Vec<(String, String, String, String)>,
48 },
49 Version {
50 versions: Vec<Version>,
51 },
52}
53
54#[derive(Clone)]
55pub enum OutputType {
56 Full,
57 Basic,
58 Single,
59}
60
61impl From<OutputTypes> for OutputType {
62 fn from(output_type: OutputTypes) -> Self {
63 match output_type {
64 OutputTypes::Full => OutputType::Full,
65 OutputTypes::Basic => OutputType::Basic,
66 OutputTypes::Single => OutputType::Single,
67 }
68 }
69}
70
71pub fn print_data(data: PrintableData, output_format: OutputValues, output_type: OutputType) {
72 match output_format {
73 OutputValues::Json => {
74 json_printer::print_json(data);
75 }
76 OutputValues::Table => match output_type {
77 OutputType::Full => {
78 table_printer::print_table_full(data);
79 }
80 OutputType::Basic => {
81 table_printer::print_table_basic(data);
82 }
83 OutputType::Single => {
84 table_printer::print_table_single(data);
85 }
86 },
87 }
88}