gq_cli/args/output/
output_format.rs1use clap::{Args, ColorChoice};
2
3#[derive(Debug, Args)]
4pub struct OutputFormat {
5 #[clap(flatten)]
6 pub indentation: Indentation,
7
8 #[clap(long, conflicts_with_all = &["indent", "tab"])]
10 pub compact: bool,
11
12 #[clap(long, default_value_t = ColorChoice::Auto)]
14 #[arg(value_enum)]
15 pub color: ColorChoice,
16}
17
18impl OutputFormat {
19 pub fn indentation(&self) -> gq_core::format::Indentation {
20 if self.compact {
21 gq_core::format::Indentation::None
22 } else {
23 self.indentation.indentation()
24 }
25 }
26}
27
28#[derive(Debug, Args)]
29pub struct Indentation {
30 #[clap(long)]
32 tab: bool,
33
34 #[clap(long, default_value_t = 2)]
36 indent: usize,
37}
38
39impl Indentation {
40 pub fn indentation(&self) -> gq_core::format::Indentation {
41 if self.tab {
42 gq_core::format::Indentation::with_tabs(self.indent)
43 } else {
44 gq_core::format::Indentation::with_spaces(self.indent)
45 }
46 }
47}