Skip to content

Commit

Permalink
fix: stdin always being read
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
Sven Lechner committed Aug 15, 2020
1 parent 0062c30 commit a065315
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
next_version: args.free()?,
};

// Check standard-in to allow for piping.
let mut piped = String::new();
io::stdin().read_line(&mut piped)?;
let piped_trim = piped.trim();
if !piped_trim.is_empty() {
args.next_version.push(piped_trim.to_string());
// Default to stdin if no version has been specified.
if args.next_version.is_empty() {
let mut piped = String::new();
io::stdin().read_line(&mut piped)?;
let piped_trim = piped.trim();
if !piped_trim.is_empty() {
args.next_version.push(piped_trim.to_string());
}
}

if args.help {
Expand Down

0 comments on commit a065315

Please sign in to comment.