diff --git a/Cargo.toml b/Cargo.toml index b0ec7ca3..b8681007 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ authors = ["Richard Newman ", "Nicholas Alexander Args { + let matches = clap::App::new("Datomish Explorer") + .version("1.0") + .author("Mozilla") + .about("An in-browser IDE for exploring a Datomish database") + .arg(clap::Arg::with_name("database") + .short("d") + .long("database") + .value_name("FILE") + .help("Path to the Datomish database to explore") + .takes_value(true) + .required(true)) + .arg(clap::Arg::with_name("port") + .short("p") + .long("port") + .value_name("INTEGER") + .help("Port to serve explorer from, i.e. `localhost:PORT`") + .default_value("3333") + .takes_value(true)) + .get_matches(); + + Args { + port: u16::from_str(matches.value_of("port").unwrap()).unwrap(), + database: matches.value_of("database").unwrap().to_string(), + } +} diff --git a/explorer/src/main.rs b/explorer/src/main.rs new file mode 100644 index 00000000..4626fef2 --- /dev/null +++ b/explorer/src/main.rs @@ -0,0 +1,27 @@ +// Copyright 2016 Mozilla +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use +// this file except in compliance with the License. You may obtain a copy of the +// License at http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software distributed +// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, either express or implied. See the License for the +// specific language governing permissions and limitations under the License. + +extern crate iron; + +mod cli; + +use cli::{get_args}; +use iron::prelude::*; +use iron::status; + +fn main() { + let args = get_args(); + fn hello_world(_: &mut Request) -> IronResult { + Ok(Response::with((status::Ok, "Hello World!"))) + } + + println!("Running Datomish Explorer at localhost:{} for database at {}", args.port, args.database); + let _server = Iron::new(hello_world).http(("localhost", args.port)).unwrap(); +}