-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add Document to common Signed-off-by: stevelr <[email protected]> * add utility for dumping smithy model in json Signed-off-by: stevelr <[email protected]> * - adds common::Document value type to correspond with smithy "Document" - adds Unit type - generate union/enums with unit type and serialized with numeric value - initial support for borrowed struct definitions - new command line utility `dump-json-model` to dump smithy model - add fixed_array and fixed_map to simplify decoding - bump weld-codegen to 0.4.3 - bump wasmbus-rpc to 0.8.4 Signed-off-by: stevelr <[email protected]> * source file for common::Document, Number, and DocumentRef Signed-off-by: stevelr <[email protected]>
- Loading branch information
Showing
18 changed files
with
1,768 additions
and
507 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//! dump model in json | ||
use anyhow::{anyhow, Context, Result}; | ||
use clap::{self, Parser}; | ||
use std::path::PathBuf; | ||
use weld_codegen::{config::CodegenConfig, sources_to_model}; | ||
|
||
#[derive(Parser, Debug)] | ||
#[clap(author, version, about, long_about = None)] | ||
struct Args { | ||
/// codegen.toml file (default: "./codegen.toml") | ||
#[clap(short, long)] | ||
config: Option<PathBuf>, | ||
} | ||
|
||
fn main() -> Result<()> { | ||
let args = Args::parse(); | ||
let config_path = args | ||
.config | ||
.unwrap_or_else(|| PathBuf::from("./codegen.toml")); | ||
if !config_path.is_file() { | ||
return Err(anyhow!("missing config file {}", &config_path.display())); | ||
} | ||
let config = std::fs::read_to_string(&config_path) | ||
.with_context(|| format!("error reading config file {}", config_path.display()))? | ||
.parse::<CodegenConfig>()?; | ||
let base_dir = config_path.parent().unwrap().to_path_buf(); | ||
let model = sources_to_model(&config.models, &base_dir, 0)?; | ||
let json_model = atelier_json::model_to_json(&model); | ||
|
||
let out = std::io::stdout(); | ||
serde_json::to_writer(&out, &json_model)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.