cbor_cli/
config.rs

1use clap::{Parser, Subcommand};
2use std::path::PathBuf;
3
4#[derive(Parser)]
5#[command(author, version, about, long_about = None)]
6pub struct Cli {
7  /// Level of verbosity
8  #[arg(short, long, action = clap::ArgAction::Count)]
9  pub verbose: u8,
10
11  /// Delimiter to use when printing multiple values
12  #[arg(short, long)]
13  pub delimiter: Option<String>,
14
15  #[command(subcommand)]
16  pub command: Option<Commands>,
17}
18
19#[derive(Subcommand)]
20pub enum Commands {
21  /// Deep inspection of CBOR files, useful for debugging, learning or repairing files.
22  Inspect {
23    #[arg(value_name = "INPUT_PATHS")]
24    input_paths: Vec<PathBuf>,
25  },
26
27  /// Convert a file of some other type to CBOR. Uses the file extension to
28  /// determine the type if not specified.
29  Import {
30    #[arg(value_name = "INPUT_PATHS")]
31    input_paths: Vec<PathBuf>,
32
33    /// Format of the input file. If not specified, the file extension will be
34    /// used to determine the type.
35    #[arg(long, value_name = "FORMAT")]
36    format: Option<String>,
37  },
38
39  /// Convert CBOR files to some other type.
40  Export {
41    #[arg(value_name = "INPUT_PATHS")]
42    input_paths: Vec<PathBuf>,
43
44    /// Format of the output file. If not specified, the file extension will be
45    /// used to determine the type.
46    #[arg(long, value_name = "FORMAT", default_value = "json")]
47    format: String,
48  },
49}
50
51pub fn get_cli() -> Cli {
52  Cli::parse()
53}