padmet/
cli.rs

1//! Command Line Interface of padmet
2
3/* std use */
4
5/* crate use */
6
7/* project use */
8
9#[derive(clap::Parser, std::fmt::Debug)]
10#[clap(
11    name = "padmet",
12    bin_name = "padmet",
13    version = "0.1.0",
14    author = "Samuel Ortion <>"
15)]
16pub struct Arguments {
17    /// Input sequence
18    #[clap(short = 'i', long = "input")]
19    input: String,
20
21    // Generic parameter
22    /// Silence all output
23    #[clap(short = 'q', long = "quiet")]
24    quiet: bool,
25
26    /// Verbose mode (-v, -vv, -vvv, etc)
27    #[clap(short = 'v', long = "verbosity", action = clap::ArgAction::Count)]
28    verbosity: u8,
29
30    /// Timestamp (sec, ms, ns, none)
31    #[clap(short = 'T', long = "timestamp")]
32    ts: Option<stderrlog::Timestamp>,
33}
34
35impl Arguments {
36    /// Get input sequence
37    pub fn input(&self) -> Vec<u8> {
38        self.input.as_bytes().to_vec()
39    }
40
41    /// Get verbosity level
42    pub fn verbosity(&self) -> usize {
43        self.verbosity as usize
44    }
45
46    /// Get quiet
47    pub fn quiet(&self) -> bool {
48        self.quiet
49    }
50
51    /// Get timestamp granularity
52    pub fn timestamp(&self) -> stderrlog::Timestamp {
53        self.ts.unwrap_or(stderrlog::Timestamp::Off)
54    }
55}