Skip to content

Commit

Permalink
lib: split comma-separated values when reading from stdin for args
Browse files Browse the repository at this point in the history
This allows `bite` rendered search output for multi-value fields to be
directly used for input values via stdin.
  • Loading branch information
radhermit committed Sep 21, 2024
1 parent 81cc65f commit 8b33503
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions crates/lib/src/args/maybe_stdin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,12 @@ where
match &source {
Source::Stdin(value) => {
let mut inner = vec![];
for arg in value.lines() {
let val = T::from_str(arg)
.map_err(|e| StdinError::FromStr(format!("{e}")))?;
inner.push(val);
for line in value.lines() {
for arg in line.split(',') {
let val =
T::from_str(arg).map_err(|e| StdinError::FromStr(format!("{e}")))?;
inner.push(val);
}
}
Ok(Self { source, inner })
}
Expand Down

0 comments on commit 8b33503

Please sign in to comment.