From a997b7b5134372bd830c60fd01a7d84933daabe4 Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Fri, 14 Dec 2018 16:43:43 -0600 Subject: [PATCH] FEATURE: Add a subcommand to describe the ucg environment variables. Also update documentation with help output. --- .../site/content/getting-started/_index.md | 10 +++++----- src/main.rs | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/docsite/site/content/getting-started/_index.md b/docsite/site/content/getting-started/_index.md index 90fea63..7dde66f 100644 --- a/docsite/site/content/getting-started/_index.md +++ b/docsite/site/content/getting-started/_index.md @@ -77,20 +77,20 @@ Ucg has builtin help on the command line. ``` $> ucg help -ucg 0.2.2 -Jeremy Wall 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 list of ucg files. converters list the available converters + env Describe the environment variables ucg uses. help Prints this message or the help of the given subcommand(s) inspect Inspect a specific symbol in a ucg file. test Check a list of ucg files for errors and run test assertions. diff --git a/src/main.rs b/src/main.rs index f32c476..6d6eb00 100644 --- a/src/main.rs +++ b/src/main.rs @@ -55,6 +55,9 @@ fn do_flags<'a, 'b>() -> clap::App<'a, 'b> { (@subcommand 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() { let mut app = do_flags(); let app_matches = app.clone().get_matches(); @@ -401,6 +419,8 @@ fn main() { test_command(matches, &import_paths, cache, ®istry, strict); } else if let Some(_) = app_matches.subcommand_matches("converters") { converters_command(®istry) + } else if let Some(_) = app_matches.subcommand_matches("env") { + env_help() } else { app.print_help().unwrap(); println!("");