json api work
This commit is contained in:
@@ -132,6 +132,14 @@ fn do_clap_matches(default_config_path: &OsStr) -> Result<clap::ArgMatches, clap
|
||||
.long("dump-txt-record")
|
||||
.help("Prints the bootstrap TXT record for this node and then quits")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("emit-schema")
|
||||
.long("emit-schema")
|
||||
.takes_value(true)
|
||||
.value_name("schema_name")
|
||||
.default_missing_value("")
|
||||
.help("Emits a JSON-Schema for a named type")
|
||||
)
|
||||
.arg(
|
||||
Arg::new("bootstrap")
|
||||
.long("bootstrap")
|
||||
|
@@ -18,6 +18,7 @@ use cfg_if::*;
|
||||
#[allow(unused_imports)]
|
||||
use color_eyre::eyre::{bail, ensure, eyre, Result as EyreResult, WrapErr};
|
||||
use server::*;
|
||||
use std::collections::HashMap;
|
||||
use std::str::FromStr;
|
||||
use tools::*;
|
||||
use tracing::*;
|
||||
@@ -71,6 +72,24 @@ fn main() -> EyreResult<()> {
|
||||
bail!("missing crypto kind");
|
||||
}
|
||||
}
|
||||
// -- Emit JSON-Schema --
|
||||
if matches.occurrences_of("emit-schema") != 0 {
|
||||
if let Some(esstr) = matches.value_of("emit-schema") {
|
||||
let mut schemas = HashMap::<String, String>::new();
|
||||
veilid_core::emit_schemas(&mut schemas);
|
||||
|
||||
if let Some(schema) = schemas.get(esstr) {
|
||||
println!("{}", schema);
|
||||
} else {
|
||||
println!("Valid schemas:");
|
||||
for s in schemas.keys() {
|
||||
println!(" {}", s);
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
// See if we're just running a quick command
|
||||
let (server_mode, success, failure) = if matches.occurrences_of("set-node-id") != 0 {
|
||||
|
Reference in New Issue
Block a user