diff --git a/README.md b/README.md index 9cbc76e..ce19cee 100644 --- a/README.md +++ b/README.md @@ -32,17 +32,21 @@ Running ucg help will show the following output. Universal Configuration Grammar compiler. USAGE: - ucg [SUBCOMMAND] + ucg [FLAGS] [SUBCOMMAND] FLAGS: - -h, --help Prints help information - -V, --version Prints version information + -h, --help Prints help information + --no-strict Turn off strict checking. + -V, --version Prints version information SUBCOMMANDS: - build Build a specific ucg file. - help Prints this message or the help of the given subcommand(s) - inspect Inspect a specific symbol in a ucg file. - test Check a specific ucg file for errors. + build Build a list of ucg files. + converters list the available converters + env Describe the environment variables ucg uses. + eval Evaluate an expression with an optional ucg file as context. + help Prints this message or the help of the given subcommand(s) + importers list the available importers for includes + test Check a list of ucg files for errors and run test assertions. ``` ## Compiling diff --git a/src/main.rs b/src/main.rs index 4580c2c..4843227 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,11 +37,11 @@ fn do_flags<'a, 'b>() -> clap::App<'a, 'b> { (author: crate_authors!()) (about: "Universal Configuration Grammar compiler.") (@arg nostrict: --("no-strict") "Turn off strict checking.") - (@subcommand inspect => - (about: "Inspect a specific symbol in a ucg file.") - (@arg expr: --expr +takes_value +required "Specify a specific binding in the ucg file to output.") - (@arg target: --format +required +takes_value "Inspect output type. (flags, json, env, exec)") - (@arg INPUT: +required "Input ucg file to inspect symbol from.") + (@subcommand eval => + (about: "Evaluate an expression with an optional ucg file as context.") + (@arg expr: --expr -e +takes_value +required "Expression to evaluate.") + (@arg target: --format +takes_value "Output type. (flags, json, env, exec) defaults to json.") + (@arg INPUT: "ucg file to use as context for the expression.") ) (@subcommand build => (about: "Build a list of ucg files.") @@ -244,9 +244,9 @@ fn inspect_command( registry: &ConverterRegistry, strict: bool, ) { - let file = matches.value_of("INPUT").unwrap(); + let file = matches.value_of("INPUT").unwrap_or("std/functional.ucg"); let sym = matches.value_of("expr"); - let target = matches.value_of("target").unwrap(); + let target = matches.value_of("target").unwrap_or("json"); let mut builder = build::FileBuilder::new(std::env::current_dir().unwrap(), import_paths, cache); builder.set_strict(strict); @@ -282,17 +282,20 @@ fn inspect_command( Some(value) => { // We use None here because we always output to stdout for an inspect. run_converter(converter, value, None).unwrap(); - eprintln!("Build successful"); + println!(""); process::exit(0); } None => { - eprintln!("Build results in no value."); + eprintln!("No value."); process::exit(1); } } } None => { - eprintln!("No such converter {}", target); + eprintln!( + "No such format {}\nrun `ucg converters` to see available formats.", + target + ); process::exit(1); } } @@ -448,7 +451,7 @@ fn main() { } else { true }; - if let Some(matches) = app_matches.subcommand_matches("inspect") { + if let Some(matches) = app_matches.subcommand_matches("eval") { inspect_command(matches, &import_paths, cache, ®istry, strict); } else if let Some(matches) = app_matches.subcommand_matches("build") { build_command(matches, &import_paths, cache, ®istry, strict);