From ab74021bae56e95abec5b53b0d276cac4f2effe3 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sat, 13 Jan 2024 10:32:54 +0100 Subject: [PATCH] Add context command --- README.md | 1 + src/args.rs | 3 +++ src/main.rs | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/README.md b/README.md index cf8ad6f..01c4a09 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ contain a `dirs.toml` file that specifies a different location. Files ending with `.tmpl` are treated as [handlebars templates](https://handlebarsjs.com/) and are processed before being written to the target location. The `.tmpl` extension will be stripped from the filename. +You can check the available context variables and their values on the system with `silo context`. ### Applying the configuration diff --git a/src/args.rs b/src/args.rs index a1e347c..011dd69 100644 --- a/src/args.rs +++ b/src/args.rs @@ -20,4 +20,7 @@ pub enum Command { Init, /// Applies the configuration stored in a silo repo Apply, + + /// Print the entire context available to templates + Context, } diff --git a/src/main.rs b/src/main.rs index c98973b..be55eab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,12 @@ fn main() -> Result<()> { match &args.command { args::Command::Init => init(&args)?, args::Command::Apply => apply(&args)?, + args::Command::Context => { + println!( + "{}", + serde_json::to_string_pretty(templating::context()).into_diagnostic()? + ) + } } Ok(())