diff options
-rw-r--r-- | src/main.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e505d6b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,41 @@ +use std::fs::File; +use std::io::{self, BufRead, BufReader, Read}; +use std::path::PathBuf; +use structopt::StructOpt; + +#[derive(Debug, StructOpt)] +#[structopt(name = "choose", about = "`choose` sections from each line of files")] +struct Opt { + /// Specify field separator other than whitespace + #[structopt(short, long, default_value = "")] + field_separator: String, + + /// Use inclusive ranges + #[structopt(short, long)] + inclusive: bool, + + /// Activate debug mode + #[structopt(short, long)] + debug: bool, + + /// Input file + #[structopt(parse(from_os_str))] + input: Option<PathBuf>, +} + +fn main() { + let opt = Opt::from_args(); + + let read = match &opt.input { + Some(f) => Box::new(File::open(f).expect("Could not open file")) as Box<Read>, + None => Box::new(io::stdin()) as Box<Read>, + }; + + let buf = BufReader::new(read); + + for line in buf.lines() { + println!("{}", line.unwrap()); + } + + println!("Hello, world!"); +} |