Skip to content

Commit

Permalink
Merge pull request #75 from dfinance/genesis-input-flags
Browse files Browse the repository at this point in the history
--genesis as json string
  • Loading branch information
mkurnikov authored May 28, 2020
2 parents 1800e43 + d60c37c commit aadda00
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions crates/move-executor/src/bin/executor_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,13 @@ fn main() -> Result<()> {
.arg(
Arg::from_usage("-m --modules [MODULE_PATHS]")
.multiple(true)
.help("Number of paths to module files / folders to use as dependencies"),
)
.arg(
Arg::from_usage("--genesis [GENESIS_JSON_FILE]")
.help("Path to .json file to use as pre-loaded chain state"),
.number_of_values(1)
.help("Path to module file / modules folder to use as dependency. \nCould be used more than once: '-m ./stdlib -m ./modules'"),
)
.arg(Arg::from_usage("--genesis [GENESIS_CONTENTS]").help("JSON-based genesis contents"))
.arg(
Arg::from_usage("--args [SCRIPT_ARGS]")
.multiple(true)
.help("Number of script main() function arguments"),
.help(r#"Number of script main() function arguments in quotes, e.g. "10 20 30""#),
)
.get_matches();

Expand All @@ -70,9 +67,8 @@ fn main() -> Result<()> {
let deps = io::load_move_module_files(modules_fpaths)?;

let genesis_json_contents = match cli_arguments.value_of("genesis") {
Some(fpath) => {
let contents = fs::read_to_string(fpath)?;
serde_json::to_value(contents)?
Some(contents) => {
serde_json::from_str(contents).context("JSON passed to --genesis is invalid")?
}
None => serde_json::json!([]),
};
Expand Down Expand Up @@ -124,5 +120,4 @@ fn main() -> Result<()> {
Err(error)
}
}
// Ok(())
}

0 comments on commit aadda00

Please sign in to comment.