1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- extern crate chrono;
- extern crate clap;
- extern crate reqwest;
- extern crate serde;
- extern crate serde_json;
-
- use clap::{App, AppSettings, Arg, SubCommand};
- use std::io;
-
- mod cli;
- mod client;
-
- fn main() -> io::Result<()> {
- let matches = App::new("snippet")
- .version("0.1.0")
- .setting(AppSettings::ArgRequiredElseHelp)
- .subcommand(
- SubCommand::with_name("new")
- .about("Creates a new snippet")
- .arg(
- Arg::with_name("name")
- .index(1)
- .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(())
- }
|