123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- extern crate chrono;
- extern crate clap;
- extern crate reqwest;
- extern crate serde;
- extern crate serde_json;
-
- use clap::{App, Arg, SubCommand};
- use std::io;
-
- mod cli;
- mod client;
-
- fn main() -> io::Result<()> {
- let matches = App::new("snippet")
- .version("0.0.1")
- .subcommand(
- SubCommand::with_name("new")
- .about("Creates a new snippet")
- .arg(
- Arg::with_name("name")
- .long("name")
- .short("n")
- .takes_value(true)
- .required(true)
- .help("The name of the snippet"),
- )
- .arg(
- Arg::with_name("file")
- .long("file")
- .short("file")
- .takes_value(true)
- .help("The file to use as the body of the snippet"),
- )
- .arg(
- Arg::with_name("filetype")
- .long("filetype")
- .short("t")
- .takes_value(true)
- .default_value("")
- .help("The filetype to use for syntax highlighting"),
- )
- .arg(
- Arg::with_name("hostname")
- .long("hostname")
- .short("s")
- .takes_value(true)
- .default_value("bngl.ws")
- .help("The hostname of the server to post your snippet to"),
- )
- .arg(
- Arg::with_name("protocol")
- .long("protocol")
- .short("c")
- .takes_value(true)
- .possible_values(&["http", "https"])
- .default_value("https")
- .help("The transport protocol to use"),
- )
- .arg(
- Arg::with_name("port")
- .long("port")
- .short("p")
- .takes_value(true)
- .default_value("80")
- .help("The transport protocol to use"),
- ),
- )
- .get_matches();
-
- if let Some(matches) = matches.subcommand_matches("new") {
- cli::new_snippet(&matches)?;
- }
-
- Ok(())
- }
|