currency_conversion_cli/
cli.rs1use clap::{Args, Parser, Subcommand};
4use clap_verbosity_flag::Verbosity;
5use rust_decimal::Decimal;
6
7#[derive(Parser, Debug)]
9#[command(version, about, long_about = None)]
10pub struct CliArgs {
11 #[command(flatten)]
12 pub verbose: Verbosity,
13
14 #[command(subcommand)]
15 pub sub_command: SubCommand,
16
17 #[arg(long)]
19 pub config_path: Option<String>,
20
21 #[arg(long)]
23 pub config_profile: Option<String>,
24}
25
26#[derive(Subcommand, Debug)]
27pub enum SubCommand {
28 Update(UpdateArgs),
30 Convert(ConvertArgs),
32 List(ListArgs),
34 Info(InfoArgs),
36 Config,
38}
39
40#[derive(Args, Debug)]
41pub struct ConvertArgs {
42 #[arg(long)]
44 pub from: String,
45 #[arg(long)]
47 pub to: String,
48 pub value: Decimal,
50}
51
52#[derive(Args, Debug)]
53pub struct ListArgs {
54 #[command(subcommand)]
56 pub dataset: ListDataSet,
57}
58
59#[derive(Debug, Subcommand)]
60pub enum ListDataSet {
61 Symbols,
62 ConversionRates,
63}
64
65#[derive(Args, Debug)]
66pub struct InfoArgs {
67 #[arg(long, action = clap::ArgAction::SetTrue)]
69 pub all: bool,
70
71 #[arg(long, action = clap::ArgAction::SetTrue)]
73 pub config: bool,
74
75 #[arg(long, action = clap::ArgAction::SetTrue)]
77 pub symbols: bool,
78
79 #[arg(long, action = clap::ArgAction::SetTrue)]
81 pub conversion_rates: bool,
82}
83
84#[derive(Debug, Args)]
85pub struct UpdateArgs {
86 #[arg(long, action = clap::ArgAction::SetTrue)]
88 pub all: bool,
89 #[arg(long, action = clap::ArgAction::SetTrue)]
91 pub symbols: bool,
92 #[arg(long, action = clap::ArgAction::SetTrue)]
94 pub conversion_rates: bool,
95}