From 1e9180edcfecd3e617b25ea3c78fe47498a25244 Mon Sep 17 00:00:00 2001 From: poltec04 Date: Sun, 5 Oct 2025 12:08:04 +0900 Subject: [PATCH 1/3] chore(echor): start from empty main.rs --- 02_echor/src/main.rs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/02_echor/src/main.rs b/02_echor/src/main.rs index 8606a41..eddce53 100644 --- a/02_echor/src/main.rs +++ b/02_echor/src/main.rs @@ -1,23 +1,3 @@ -use clap::Parser; - -#[derive(Debug, Parser)] -#[command(author, version, about)] -/// Rust version of `echo` -struct Args { - /// Input text - #[arg(required(true))] - text: Vec, - - /// Do not print newline - #[arg(short('n'))] - omit_newline: bool, -} - fn main() { - let args = Args::parse(); - print!( - "{}{}", - args.text.join(" "), - if args.omit_newline { "" } else { "\n" } - ); +// TODO: clap(derive)で引数を定義してechoを実装 } From 8a3303adb6a37636082960cf4db733f82bcf4ff9 Mon Sep 17 00:00:00 2001 From: poltec04 Date: Sat, 11 Oct 2025 18:00:38 +0900 Subject: [PATCH 2/3] feat(echor): define Args with clap derive --- 02_echor/src/main.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/02_echor/src/main.rs b/02_echor/src/main.rs index eddce53..b8ccfc6 100644 --- a/02_echor/src/main.rs +++ b/02_echor/src/main.rs @@ -1,3 +1,22 @@ +use clap::Parser; + +#[derive(Debug, Parser)] +#[command(author, version, about)] +/// Rust version of 'echo' +struct Args { + /// Input text + #[arg(required(true))] + text: Vec, + + /// Do not print newline + #[arg(short('n'))] + omit_newline: bool, +} fn main() { -// TODO: clap(derive)で引数を定義してechoを実装 + let args = Args::parse(); + print!( + "{}{}", + args.text.join(" "), + if args.omit_newline { "" } else { "\n" } + ); } From 8c955c5e9f4b6af5b3abf84b5941a5c449edabe3 Mon Sep 17 00:00:00 2001 From: poltec04 Date: Thu, 16 Oct 2025 22:39:22 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix(echor):=20clap=20derive=E3=80=80?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02_echor/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/02_echor/src/main.rs b/02_echor/src/main.rs index b8ccfc6..8606a41 100644 --- a/02_echor/src/main.rs +++ b/02_echor/src/main.rs @@ -2,7 +2,7 @@ use clap::Parser; #[derive(Debug, Parser)] #[command(author, version, about)] -/// Rust version of 'echo' +/// Rust version of `echo` struct Args { /// Input text #[arg(required(true))] @@ -12,6 +12,7 @@ struct Args { #[arg(short('n'))] omit_newline: bool, } + fn main() { let args = Args::parse(); print!(