123456789101112131415161718192021 |
- use clap::ArgMatches;
- use std::fs;
- use std::io;
-
- pub fn new_gist(matches: &ArgMatches) -> io::Result<()> {
- let title = matches.value_of("title").unwrap();
- let input = matches.value_of("input");
-
- let mut rdr: Box<io::Read> = match input {
- Some(file) => Box::new(fs::File::open(file)?),
- None => Box::new(io::stdin()),
- };
-
- let mut body = String::new();
- rdr.read_to_string(&mut body)?;
-
- println!("title: {}", title);
- println!("body: {}", body);
-
- Ok(())
- }
|