|
|
@@ -2,9 +2,9 @@ use clap::ArgMatches;
|
|
2
|
2
|
use std::fs;
|
|
3
|
3
|
use std::io;
|
|
4
|
4
|
|
|
5
|
|
-use crate::client::{create_gist, OutgoingGist, ServerConfig};
|
|
|
5
|
+use crate::client::{create_snippet, OutgoingSnippet, ServerConfig};
|
|
6
|
6
|
|
|
7
|
|
-fn get_gist_from_matches(matches: &ArgMatches) -> io::Result<OutgoingGist> {
|
|
|
7
|
+fn get_snippet_from_matches(matches: &ArgMatches) -> io::Result<OutgoingSnippet> {
|
|
8
|
8
|
let title = matches.value_of("name").unwrap();
|
|
9
|
9
|
let input = matches.value_of("file");
|
|
10
|
10
|
let filetype = matches.value_of("filetype").unwrap();
|
|
|
@@ -17,7 +17,7 @@ fn get_gist_from_matches(matches: &ArgMatches) -> io::Result<OutgoingGist> {
|
|
17
|
17
|
let mut body = String::new();
|
|
18
|
18
|
rdr.read_to_string(&mut body)?;
|
|
19
|
19
|
|
|
20
|
|
- Ok(OutgoingGist {
|
|
|
20
|
+ Ok(OutgoingSnippet {
|
|
21
|
21
|
title: title.to_string(),
|
|
22
|
22
|
body,
|
|
23
|
23
|
filetype: filetype.to_string(),
|
|
|
@@ -36,13 +36,13 @@ fn get_server_config_from_matches(matches: &ArgMatches) -> ServerConfig {
|
|
36
|
36
|
}
|
|
37
|
37
|
}
|
|
38
|
38
|
|
|
39
|
|
-pub fn new_gist(matches: &ArgMatches) -> io::Result<()> {
|
|
40
|
|
- let gist = get_gist_from_matches(matches)?;
|
|
|
39
|
+pub fn new_snippet(matches: &ArgMatches) -> io::Result<()> {
|
|
|
40
|
+ let snippet = get_snippet_from_matches(matches)?;
|
|
41
|
41
|
let config = get_server_config_from_matches(matches);
|
|
42
|
42
|
|
|
43
|
|
- match create_gist(gist, &config) {
|
|
|
43
|
+ match create_snippet(snippet, &config) {
|
|
44
|
44
|
Ok(resp) => println!(
|
|
45
|
|
- "Success! Your new gist is available at {}://{}:{}/gists/{}",
|
|
|
45
|
+ "Success! Your new snippet is available at {}://{}:{}/snippets/{}",
|
|
46
|
46
|
config.protocol, config.hostname, config.port, resp.id
|
|
47
|
47
|
),
|
|
48
|
48
|
Err(err) => println!("{}", err),
|