Build in client if no server
This commit is contained in:
parent
be1f064c4d
commit
96189faf3f
|
@ -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<Item=(), Error=()> {
|
||||
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);
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue