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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. extern crate chrono;
  2. extern crate clap;
  3. extern crate reqwest;
  4. extern crate serde;
  5. extern crate serde_json;
  6. use clap::{App, Arg, SubCommand};
  7. use std::io;
  8. mod cli;
  9. mod client;
  10. fn main() -> io::Result<()> {
  11. let matches = App::new("gist")
  12. .version("0.0.1")
  13. .subcommand(
  14. SubCommand::with_name("new")
  15. .about("Creates a new gist")
  16. .arg(
  17. Arg::with_name("name")
  18. .long("name")
  19. .short("n")
  20. .takes_value(true)
  21. .required(true)
  22. .help("The name of the gist"),
  23. )
  24. .arg(
  25. Arg::with_name("file")
  26. .long("file")
  27. .short("file")
  28. .takes_value(true)
  29. .help("The file to use as the body of the gist"),
  30. )
  31. .arg(
  32. Arg::with_name("filetype")
  33. .long("filetype")
  34. .short("t")
  35. .takes_value(true)
  36. .default_value("")
  37. .help("The filetype to use for syntax highlighting"),
  38. )
  39. .arg(
  40. Arg::with_name("hostname")
  41. .long("hostname")
  42. .short("s")
  43. .takes_value(true)
  44. .default_value("bngl.ws")
  45. .help("The hostname of the server to post your gist to"),
  46. )
  47. .arg(
  48. Arg::with_name("protocol")
  49. .long("protocol")
  50. .short("c")
  51. .takes_value(true)
  52. .possible_values(&["http", "https"])
  53. .default_value("https")
  54. .help("The transport protocol to use"),
  55. )
  56. .arg(
  57. Arg::with_name("port")
  58. .long("port")
  59. .short("p")
  60. .takes_value(true)
  61. .default_value("80")
  62. .help("The transport protocol to use"),
  63. ),
  64. )
  65. .get_matches();
  66. if let Some(matches) = matches.subcommand_matches("new") {
  67. cli::new_gist(&matches)?;
  68. }
  69. Ok(())
  70. }