Skip to content

Commit e91f9f1

Browse files
authored
Merge pull request #17 from dimacurrentai/windsurf
Windsurf live/vibe coding quick session.
2 parents 6da7996 + 7391f54 commit e91f9f1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

step01_cmdline/code/src/main.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11
use clap::Parser;
22

3+
#[derive(Parser, clap::ValueEnum, Clone, Debug)]
4+
enum Operation {
5+
Add,
6+
Mul,
7+
}
8+
39
#[derive(Parser)]
410
struct Args {
511
#[arg(long)]
612
a: i8,
713
#[arg(long)]
814
b: i8,
15+
#[arg(long, value_enum, default_value_t = Operation::Add)]
16+
op: Operation,
917
}
1018

1119
fn main() {
1220
let args = Args::parse();
13-
println!("{} + {} = {}", args.a, args.b, args.a + args.b);
14-
}
21+
let (result, op_symbol) = match args.op {
22+
Operation::Add => (args.a + args.b, '+'),
23+
Operation::Mul => (args.a * args.b, '*'),
24+
};
25+
println!("{} {} {} = {}", args.a, op_symbol, args.b, result);
26+
}

step01_cmdline/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ set -e
55
docker build -f ../Dockerfile.template . -t demo
66
docker run --rm -t demo --a 1 --b 2 && echo OK
77
docker run --rm -t demo --a 3 --b 4 && echo OK
8+
docker run --rm -t demo --a 3 --b 4 --op mul && echo OK
89
docker run --rm -t demo --a 100 --b 100 && (echo "Error, should overflow."; exit 1)
910
echo "Oveflow handled correctly."

0 commit comments

Comments
 (0)