Skip to content

Commit a5cfa9d

Browse files
committed
Abstract paths from stdin
1 parent b90ed66 commit a5cfa9d

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

src/main.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,7 @@ fn main() -> Result<()> {
3232
match cli.command {
3333
Command::Find { paths } => {
3434
let paths = if paths.is_empty() {
35-
stdin()
36-
.lines()
37-
.filter_map(|line| {
38-
let line = line.ok()?;
39-
if line.is_empty() {
40-
return None;
41-
}
42-
Some(line.to_string())
43-
})
44-
.collect::<Vec<_>>()
35+
paths_from_stdin()
4536
} else {
4637
paths
4738
};
@@ -50,3 +41,16 @@ fn main() -> Result<()> {
5041
}
5142
}
5243
}
44+
45+
fn paths_from_stdin() -> Vec<String> {
46+
stdin()
47+
.lines()
48+
.filter_map(|line| {
49+
let line = line.ok()?.trim().to_string();
50+
if line.is_empty() {
51+
return None;
52+
}
53+
Some(line)
54+
})
55+
.collect::<Vec<_>>()
56+
}

0 commit comments

Comments
 (0)