|
@@ -2,7 +2,7 @@ use clap::ArgMatches;
|
2
|
2
|
use std::fs;
|
3
|
3
|
use std::io;
|
4
|
4
|
|
5
|
|
-use crate::client::{create_snippet, OutgoingSnippet, ServerConfig};
|
|
5
|
+use crate::client::{build_url_from_config, create_snippet, OutgoingSnippet, ServerConfig};
|
6
|
6
|
|
7
|
7
|
fn get_snippet_from_matches(matches: &ArgMatches) -> io::Result<OutgoingSnippet> {
|
8
|
8
|
let title = matches.value_of("name").unwrap();
|
|
@@ -38,13 +38,13 @@ fn get_server_config_from_matches(matches: &ArgMatches) -> ServerConfig {
|
38
|
38
|
|
39
|
39
|
pub fn new_snippet(matches: &ArgMatches) -> io::Result<()> {
|
40
|
40
|
let snippet = get_snippet_from_matches(matches)?;
|
41
|
|
- println!("{:?}", snippet);
|
42
|
41
|
let config = get_server_config_from_matches(matches);
|
|
42
|
+ let url = build_url_from_config(&config);
|
43
|
43
|
|
44
|
44
|
match create_snippet(snippet, &config) {
|
45
|
45
|
Ok(resp) => println!(
|
46
|
|
- "Success! Your new snippet is available at {}://{}:{}/snippets/{}",
|
47
|
|
- config.protocol, config.hostname, config.port, resp.id
|
|
46
|
+ "Success! Your new snippet is available at {}/snippets/{}",
|
|
47
|
+ url, resp.id
|
48
|
48
|
),
|
49
|
49
|
Err(err) => println!("{}", err),
|
50
|
50
|
}
|