FEATURE: Add a subcommand to describe the ucg environment variables.

Also update documentation with help output.
This commit is contained in:
Jeremy Wall 2018-12-14 16:43:43 -06:00
parent 821f1e9fb2
commit a997b7b513
2 changed files with 25 additions and 5 deletions

View File

@ -77,20 +77,20 @@ Ucg has builtin help on the command line.
``` ```
$> ucg help $> ucg help
ucg 0.2.2
Jeremy Wall <jeremy@marzhillstudios.com>
Universal Configuration Grammar compiler. Universal Configuration Grammar compiler.
USAGE: USAGE:
ucg [SUBCOMMAND] ucg [FLAGS] [SUBCOMMAND]
FLAGS: FLAGS:
-h, --help Prints help information -h, --help Prints help information
-V, --version Prints version information --no-strict Turn off strict checking.
-V, --version Prints version information
SUBCOMMANDS: SUBCOMMANDS:
build Build a list of ucg files. build Build a list of ucg files.
converters list the available converters converters list the available converters
env Describe the environment variables ucg uses.
help Prints this message or the help of the given subcommand(s) help Prints this message or the help of the given subcommand(s)
inspect Inspect a specific symbol in a ucg file. inspect Inspect a specific symbol in a ucg file.
test Check a list of ucg files for errors and run test assertions. test Check a list of ucg files for errors and run test assertions.

View File

@ -55,6 +55,9 @@ fn do_flags<'a, 'b>() -> clap::App<'a, 'b> {
(@subcommand converters => (@subcommand converters =>
(about: "list the available converters") (about: "list the available converters")
) )
(@subcommand env =>
(about: "Describe the environment variables ucg uses.")
)
) )
} }
@ -377,6 +380,21 @@ fn converters_command(registry: &ConverterRegistry) {
} }
} }
fn env_help() {
println!("Universal Configuration Grammar compiler.");
println!("");
println!("ENVIRONMENT VARIABLES:");
println!("");
println!(
"
UCG_IMPORT_PATH=\"{}\"
A list of paths to search for imports from. Uses the same syntax
as your platforms $PATH environment variable.
",
std::env::var("UCG_IMPORT_PATH").unwrap_or(String::new())
);
}
fn main() { fn main() {
let mut app = do_flags(); let mut app = do_flags();
let app_matches = app.clone().get_matches(); let app_matches = app.clone().get_matches();
@ -401,6 +419,8 @@ fn main() {
test_command(matches, &import_paths, cache, &registry, strict); test_command(matches, &import_paths, cache, &registry, strict);
} else if let Some(_) = app_matches.subcommand_matches("converters") { } else if let Some(_) = app_matches.subcommand_matches("converters") {
converters_command(&registry) converters_command(&registry)
} else if let Some(_) = app_matches.subcommand_matches("env") {
env_help()
} else { } else {
app.print_help().unwrap(); app.print_help().unwrap();
println!(""); println!("");