Compare commits
1 commit
master
...
database-e
Author | SHA1 | Date | |
---|---|---|---|
|
c6b7f09d39 |
5 changed files with 90 additions and 1 deletions
|
@ -11,6 +11,9 @@ authors = ["Richard Newman <rnewman@twinql.com>", "Nicholas Alexander <nalexande
|
||||||
[dev-dependencies.datomish-cli]
|
[dev-dependencies.datomish-cli]
|
||||||
path = "cli"
|
path = "cli"
|
||||||
|
|
||||||
|
[dev-dependencies.datomish-explorer]
|
||||||
|
path = "explorer"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "datomish-cli"
|
name = "datomish-cli"
|
||||||
path = "cli/src/main.rs"
|
path = "cli/src/main.rs"
|
11
explorer/Cargo.toml
Normal file
11
explorer/Cargo.toml
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "datomish-explorer"
|
||||||
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
iron = "0.4.x"
|
||||||
|
toml = "0.2.1"
|
||||||
|
clap = "2.19.3"
|
||||||
|
|
||||||
|
[dependencies.datomish]
|
||||||
|
path = "../"
|
3
explorer/README.md
Normal file
3
explorer/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# datomish-explorer
|
||||||
|
|
||||||
|
An in-browser IDE for exploring a Datomish database.
|
45
explorer/src/cli.rs
Normal file
45
explorer/src/cli.rs
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// 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 clap;
|
||||||
|
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
pub struct Args {
|
||||||
|
pub database: String,
|
||||||
|
pub port: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_args() -> 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(),
|
||||||
|
}
|
||||||
|
}
|
27
explorer/src/main.rs
Normal file
27
explorer/src/main.rs
Normal file
|
@ -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<Response> {
|
||||||
|
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();
|
||||||
|
}
|
Loading…
Reference in a new issue