kelper/cli/formats.rs
1use clap::ValueEnum;
2use std::fmt;
3
4/// Logging format options for Kelper
5#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Eq)]
6pub enum LogFormat {
7 /// Plain text format, better for local development
8 Plain,
9 /// JSON format, better for production and machine parsing
10 Json,
11}
12
13impl fmt::Display for LogFormat {
14 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15 match self {
16 LogFormat::Plain => write!(f, "plain"),
17 LogFormat::Json => write!(f, "json"),
18 }
19 }
20}
21
22/// Output format options for displaying Kubernetes resource data
23#[derive(Debug, Clone, Copy, ValueEnum, PartialEq, Eq)]
24pub enum OutputFormat {
25 /// Standard output format with essential columns
26 Normal,
27 /// Extended output format with additional columns
28 Wide,
29}
30
31impl fmt::Display for OutputFormat {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 match self {
34 OutputFormat::Normal => write!(f, "normal"),
35 OutputFormat::Wide => write!(f, "wide"),
36 }
37 }
38}
39
40impl OutputFormat {
41 /// Check if this format includes registry information
42 ///
43 /// # Returns
44 ///
45 /// * `bool` - True if the format includes registry information
46 pub fn includes_registry(&self) -> bool {
47 matches!(self, OutputFormat::Wide)
48 }
49
50 /// Check if this format includes digest information
51 ///
52 /// # Returns
53 ///
54 /// * `bool` - True if the format includes digest information
55 pub fn includes_digest(&self) -> bool {
56 matches!(self, OutputFormat::Wide)
57 }
58
59 /// Check if this format includes node information
60 ///
61 /// # Returns
62 ///
63 /// * `bool` - True if the format includes node information
64 pub fn includes_node(&self) -> bool {
65 matches!(self, OutputFormat::Wide)
66 }
67}