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 hyper;
|
||||||
|
extern crate mars;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
|
|
||||||
|
use colored::*;
|
||||||
|
|
||||||
use hyper::Client;
|
use hyper::Client;
|
||||||
use hyper::rt::{self, Future};
|
use hyper::rt::{self, Future};
|
||||||
|
|
||||||
|
use mars::GeneralBuilder;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
let current_dir = match env::current_dir() {
|
let current_dir = match env::current_dir() {
|
||||||
|
@ -27,11 +33,13 @@ fn main() {
|
||||||
|
|
||||||
fn fetch_url(url: hyper::Uri) -> impl Future<Item=(), Error=()> {
|
fn fetch_url(url: hyper::Uri) -> impl Future<Item=(), Error=()> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
|
let path = url.path().to_owned();
|
||||||
client.get(url)
|
client.get(url)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
// If there was an error, let the user know...
|
// If there was an error, build in client
|
||||||
.map_err(|err| {
|
.map_err(move |_| {
|
||||||
eprintln!("Error {}", err);
|
eprintln!("{}", "Server not listening, building in client...".bold().yellow());
|
||||||
|
let builder = GeneralBuilder::new();
|
||||||
|
let _ = builder.build(&path);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue