libmactime2/
cli.rs

1
2use clap::{Parser};
3use crate::{OutputFormat};
4
5
6#[cfg(feature = "gzip")]
7const BODYFILE_HELP: &str = "path to input file or '-' for stdin (files ending with .gz will be treated as being gzipped)";
8#[cfg(not(feature = "gzip"))]
9const BODYFILE_HELP: &str = "path to input file or '-' for stdin";
10
11#[derive(Parser)]
12#[clap(author, version, about, long_about = None)]
13pub struct Cli {
14    #[clap(short('b'), default_value="-", help=BODYFILE_HELP, display_order(100))]
15    pub(crate) input_file: String,
16
17    /// output format, if not specified, default value is 'txt'
18    #[clap(short('F'), long("format"), value_enum, display_order(600))]
19    pub(crate) output_format: Option<OutputFormat>,
20
21    /// output as CSV instead of TXT. This is a conveniance option, which is identical to `--format=csv`
22    /// and will be removed in a future release. If you specified `--format` and `-d`, the latter will be ignored.
23    #[clap(short('d'), display_order(610))]
24    pub(crate) csv_format: bool,
25
26    /// output as JSON instead of TXT. This is a conveniance option, which is identical to `--format=json`
27    /// and will be removed in a future release. If you specified `--format` and `-j`, the latter will be ignored.
28    #[clap(short('j'), display_order(620))]
29    pub(crate) json_format: bool,
30
31    /// name of offset of source timezone (or 'list' to display all possible values
32    #[clap(short('f'), long("from-timezone"), display_order(300))]
33    pub(crate) src_zone: Option<String>,
34
35    /// name of offset of destination timezone (or 'list' to display all possible values
36    #[clap(short('t'), long("to-timezone"), display_order(400))]
37    pub(crate) dst_zone: Option<String>,
38
39    // /// convert only, but do not sort
40    // #[clap(short('c'), long("convert-only"), display_order(450))]
41    // pub(crate) dont_sort: bool,
42
43    /// strict mode: do not only warn, but abort if an error occurs
44    #[clap(long("strict"), display_order(500))]
45    pub(crate) strict_mode: bool,
46
47    #[clap(flatten)]
48    pub(crate) verbose: clap_verbosity_flag::Verbosity,
49}
50
51impl Cli {
52    pub fn verbose(&self) -> &clap_verbosity_flag::Verbosity {
53        &self.verbose
54    }
55
56    pub fn src_zone(&self) -> &Option<String> {
57        &self.src_zone
58    }
59
60    pub fn dst_zone(&self) -> &Option<String> {
61        &self.dst_zone
62    }
63}