The CLI frontend to a gist server written in Rust
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cli.rs 503B

123456789101112131415161718192021
  1. use clap::ArgMatches;
  2. use std::fs;
  3. use std::io;
  4. pub fn new_gist(matches: &ArgMatches) -> io::Result<()> {
  5. let title = matches.value_of("title").unwrap();
  6. let input = matches.value_of("input");
  7. let mut rdr: Box<io::Read> = match input {
  8. Some(file) => Box::new(fs::File::open(file)?),
  9. None => Box::new(io::stdin()),
  10. };
  11. let mut body = String::new();
  12. rdr.read_to_string(&mut body)?;
  13. println!("title: {}", title);
  14. println!("body: {}", body);
  15. Ok(())
  16. }