Skip to content

Commit

Permalink
adding clap
Browse files Browse the repository at this point in the history
  • Loading branch information
Afag-Ramazanova committed Dec 13, 2024
1 parent 7025d29 commit ec62690
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 6 deletions.
56 changes: 55 additions & 1 deletion multiplication2/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion multiplication2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
clap = "4.5.20"
clap = { version = "4.0", features = ["derive"] }
sqlite = "0.36.1"

19 changes: 15 additions & 4 deletions multiplication2/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
use clap::Parser;
use multiplication2::multiplication;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
a: i32,
b: i32,
}

fn main() {
let a = 5;
let b = 15;
let result = multiplication(&a, &b);
println!("The multiplication of {} and {} is {}", a, b, result);
let args = Args::parse();

let result = multiplication(&args.a, &args.b);
println!(
"The multiplication of {} and {} is {}",
args.a, args.b, result
);
}

0 comments on commit ec62690

Please sign in to comment.