-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmod.rs
More file actions
38 lines (33 loc) · 994 Bytes
/
mod.rs
File metadata and controls
38 lines (33 loc) · 994 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use clap::Parser;
use orfile::Orfile;
use serde::{Deserialize, Serialize};
/// The arguments for the add command
///
/// We define this as a separate struct because Orfile requires separate config structs to allow composability and discretion between mandatory and `using` enabled fields.
#[derive(Parser, Debug, Clone, Serialize, Deserialize)]
#[clap(rename_all = "kebab-case")]
pub struct AddArgs {
/// The left number
#[clap(long)]
pub left: u64,
/// The right number
#[clap(long)]
pub right: u64,
}
/// The add command
///
/// The [Orfile] macro derive will generate a module or_file with a struct [or_file::Add] which contains the `where` and `using` subcommands.
#[derive(Parser, Debug, Clone, Orfile)]
#[clap(rename_all = "kebab-case")]
pub struct Add {
#[orfile(config)]
#[clap(flatten)]
pub args: AddArgs,
}
impl Add {
pub async fn execute(&self) -> Result<(), anyhow::Error> {
println!("{:?}", self);
println!("{}", self.args.left + self.args.right);
Ok(())
}
}