Browse Source

Add a `--open` option `graph` command to open graph in browser automatically

tags/v0.0.0-test.4
Philipp Oppermann 3 years ago
parent
commit
4e30103215
Failed to extract signature
3 changed files with 265 additions and 3 deletions
  1. +252
    -0
      Cargo.lock
  2. +1
    -0
      binaries/cli/Cargo.toml
  3. +12
    -3
      binaries/cli/src/main.rs

+ 252
- 0
Cargo.lock View File

@@ -389,6 +389,12 @@ version = "1.0.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11"

[[package]]
name = "cesu8"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"

[[package]]
name = "cfg-if"
version = "1.0.0"
@@ -474,6 +480,16 @@ dependencies = [
"unicode-width",
]

[[package]]
name = "combine"
version = "4.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4"
dependencies = [
"bytes",
"memchr",
]

[[package]]
name = "communication-layer-pub-sub"
version = "0.1.0"
@@ -659,6 +675,12 @@ dependencies = [
"syn",
]

[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"

[[package]]
name = "cxx"
version = "1.0.73"
@@ -727,6 +749,41 @@ dependencies = [
"syn",
]

[[package]]
name = "darling"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
dependencies = [
"darling_core",
"darling_macro",
]

[[package]]
name = "darling_core"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"syn",
]

[[package]]
name = "darling_macro"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
dependencies = [
"darling_core",
"quote",
"syn",
]

[[package]]
name = "dashmap"
version = "4.0.2"
@@ -795,6 +852,7 @@ dependencies = [
"eyre",
"serde_yaml 0.9.11",
"tempfile",
"webbrowser",
]

[[package]]
@@ -1479,6 +1537,12 @@ dependencies = [
"thiserror",
]

[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"

[[package]]
name = "idna"
version = "0.2.3"
@@ -1576,6 +1640,26 @@ version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"

[[package]]
name = "jni"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6df18c2e3db7e453d3c6ac5b3e9d5182664d28788126d39b91f2d1e22b017ec"
dependencies = [
"cesu8",
"combine",
"jni-sys",
"log",
"thiserror",
"walkdir",
]

[[package]]
name = "jni-sys"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"

[[package]]
name = "js-sys"
version = "0.3.56"
@@ -1692,6 +1776,15 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26a8d2502d5aa4d411ef494ba7470eb299f05725179ce3b5de77aa01a9ffdea"

[[package]]
name = "malloc_buf"
version = "0.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb"
dependencies = [
"libc",
]

[[package]]
name = "maplit"
version = "1.0.2"
@@ -1869,6 +1962,64 @@ name = "napi-sys"
version = "1.0.0"
source = "git+https://github.com/getditto/napi-rs?branch=ditto/closure-into-jsfunction#da095cc3f1af133344083b525d7e9763b347e249"

[[package]]
name = "ndk"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0"
dependencies = [
"bitflags",
"jni-sys",
"ndk-sys",
"num_enum",
"raw-window-handle",
"thiserror",
]

[[package]]
name = "ndk-context"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"

[[package]]
name = "ndk-glue"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
dependencies = [
"libc",
"log",
"ndk",
"ndk-context",
"ndk-macro",
"ndk-sys",
"once_cell",
"parking_lot",
]

[[package]]
name = "ndk-macro"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c"
dependencies = [
"darling",
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]

[[package]]
name = "ndk-sys"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046"
dependencies = [
"jni-sys",
]

[[package]]
name = "nix"
version = "0.22.3"
@@ -1963,6 +2114,27 @@ dependencies = [
"libc",
]

[[package]]
name = "num_enum"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9"
dependencies = [
"num_enum_derive",
]

[[package]]
name = "num_enum_derive"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn",
]

[[package]]
name = "num_threads"
version = "0.1.5"
@@ -1972,6 +2144,15 @@ dependencies = [
"libc",
]

[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
]

[[package]]
name = "once_cell"
version = "1.13.0"
@@ -2372,6 +2553,17 @@ dependencies = [
"syn",
]

[[package]]
name = "proc-macro-crate"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9"
dependencies = [
"once_cell",
"thiserror",
"toml",
]

[[package]]
name = "proc-macro-error"
version = "1.0.4"
@@ -2616,6 +2808,15 @@ dependencies = [
"getrandom",
]

[[package]]
name = "raw-window-handle"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a"
dependencies = [
"cty",
]

[[package]]
name = "rayon"
version = "1.5.1"
@@ -2875,6 +3076,15 @@ dependencies = [
"syn",
]

[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]

[[package]]
name = "schannel"
version = "0.1.19"
@@ -3391,6 +3601,15 @@ dependencies = [
"tracing",
]

[[package]]
name = "toml"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7"
dependencies = [
"serde",
]

[[package]]
name = "tonic"
version = "0.6.2"
@@ -3746,6 +3965,17 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"

[[package]]
name = "walkdir"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]

[[package]]
name = "want"
version = "0.3.0"
@@ -3846,6 +4076,22 @@ dependencies = [
"wasm-bindgen",
]

[[package]]
name = "webbrowser"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01d62aa75495ab67cdc273d0b95cc76bcedfea2ba28338a4cf9b4137949dfac5"
dependencies = [
"jni",
"ndk-glue",
"objc",
"raw-window-handle",
"url",
"web-sys",
"widestring",
"winapi",
]

[[package]]
name = "webpki"
version = "0.21.4"
@@ -3895,6 +4141,12 @@ dependencies = [
"libc",
]

[[package]]
name = "widestring"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "653f141f39ec16bba3c5abe400a0c60da7468261cc2cbf36805022876bc721a8"

[[package]]
name = "winapi"
version = "0.3.9"


+ 1
- 0
binaries/cli/Cargo.toml View File

@@ -15,3 +15,4 @@ eyre = "0.6.8"
dora-core = { path = "../../libraries/core" }
serde_yaml = "0.9.11"
tempfile = "3.3.0"
webbrowser = "0.8.0"

+ 12
- 3
binaries/cli/src/main.rs View File

@@ -24,6 +24,8 @@ enum Command {
dataflow: PathBuf,
#[clap(long, action)]
mermaid: bool,
#[clap(long, action)]
open: bool,
},
Build {
dataflow: PathBuf,
@@ -48,7 +50,11 @@ fn main() -> eyre::Result<()> {
dataflow,
runtime_path,
} => check::check(&dataflow, &runtime_path)?,
Command::Graph { dataflow, mermaid } => {
Command::Graph {
dataflow,
mermaid,
open,
} => {
if mermaid {
let visualized = graph::visualize_as_mermaid(&dataflow)?;
println!("{visualized}");
@@ -61,14 +67,17 @@ fn main() -> eyre::Result<()> {
let mut file = NamedTempFile::new().context("failed to create temp file")?;
file.as_file_mut().write_all(html.as_bytes())?;

let path = file.path();
let path = file.path().to_owned();
file.keep()?;

println!(
"View graph by opening the following in your browser:\n file://{}",
path.display()
);

file.keep()?;
if open {
webbrowser::open(path.as_os_str().to_str().unwrap())?;
}
}
}
Command::Build { dataflow } => {


Loading…
Cancel
Save