aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-06-02 21:02:11 -0400
committerbnewbold <bnewbold@robocracy.org>2016-06-02 21:02:11 -0400
commit5ca100e6f085bad332df16580e6b292b24e01317 (patch)
tree2b5d09097fabe8ba1c8823ed7003c6a872cf31a6 /src/main.rs
parent220e7ccb16311a390504a10f42ba1a1290b0630b (diff)
downloaducp-5ca100e6f085bad332df16580e6b292b24e01317.tar.gz
ucp-5ca100e6f085bad332df16580e6b292b24e01317.zip
start cleaning up error conditions
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index 1077034..95e2dd0 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,7 +12,7 @@ mod server;
mod common;
mod udt_extras;
mod crypto;
-
+use std::io::Write;
use std::str;
use std::env;
use std::process::exit;
@@ -75,7 +75,7 @@ fn main() {
}
}
-
+ let mut ret: Result<(), String>;
match (srcfile.contains(":"), destfile.contains(":")) {
(true, true) => { println!("Can't have src and dest both be remote!"); exit(-1); },
(false, false) => { println!("One of src or dest should be remote!"); exit(-1); },
@@ -85,7 +85,7 @@ fn main() {
let spl: Vec<&str> = srcfile.split(":").collect();
let host = spl[0];
let remote_file = spl[1];
- client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto);
+ ret = client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto);
},
(false, true) => {
let is_recv = false;
@@ -93,7 +93,15 @@ fn main() {
let spl: Vec<&str> = destfile.split(":").collect();
let host = spl[0];
let remote_file = spl[1];
- client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto);
+ ret = client::run_client(host, local_file, remote_file, recursive, is_recv, no_crypto);
},
}
+
+ match ret {
+ Ok(_) => { exit(0); },
+ Err(msg) => {
+ writeln!(&mut ::std::io::stderr(), "{}", msg).unwrap();
+ exit(-1);
+ }
+ }
}