From 96189faf3f12a6a4c729bcf1334de01279b85bbb Mon Sep 17 00:00:00 2001 From: Thomas Forgione Date: Tue, 25 Sep 2018 14:58:01 +0200 Subject: [PATCH] Build in client if no server --- src/client.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/client.rs b/src/client.rs index 9b23e6b..ad3aa3b 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,11 +1,17 @@ +extern crate colored; extern crate hyper; +extern crate mars; use std::env; use std::process::exit; +use colored::*; + use hyper::Client; use hyper::rt::{self, Future}; +use mars::GeneralBuilder; + fn main() { let current_dir = match env::current_dir() { @@ -27,11 +33,13 @@ fn main() { fn fetch_url(url: hyper::Uri) -> impl Future { let client = Client::new(); - + let path = url.path().to_owned(); client.get(url) .map(|_| ()) - // If there was an error, let the user know... - .map_err(|err| { - eprintln!("Error {}", err); + // If there was an error, build in client + .map_err(move |_| { + eprintln!("{}", "Server not listening, building in client...".bold().yellow()); + let builder = GeneralBuilder::new(); + let _ = builder.build(&path); }) }