Skip to content

Commit

Permalink
read lines from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Aug 24, 2021
1 parent 07a4026 commit 5e17a28
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main.rs
@@ -1,5 +1,6 @@
use clap::{crate_authors, crate_version, App, Arg};
use color_eyre::eyre::Result;
use color_eyre::eyre::{ContextCompat, Result, WrapErr};
use std::io::{self, stdin, BufRead};

fn main() {
if let Err(err) = try_main() {
Expand All @@ -22,7 +23,17 @@ fn try_main() -> Result<()> {
.required(true)
).get_matches();

println!("{:?}", matches);
let target = matches.value_of("target").context(
"could not get the target value. This is an internal error and should be reported.",
)?;

let lines: Vec<String> = stdin()
.lock()
.lines()
.collect::<io::Result<Vec<String>>>()
.context("could not read lines from stdin")?;

println!("{:?}", lines);

Ok(())
}

0 comments on commit 5e17a28

Please sign in to comment.