diff --git a/src/config.rs b/src/config.rs index 528ba34c..49760c5c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,6 +13,8 @@ use structopt::StructOpt; use strum::{EnumIter, EnumString, EnumVariantNames, IntoEnumIterator, VariantNames}; use which_crate::which; +pub static EXAMPLE_CONFIG: &str = include_str!("../config.example.toml"); + #[allow(unused_macros)] macro_rules! str_value { ($section:ident, $value:ident) => { @@ -195,7 +197,7 @@ impl ConfigFile { if !config_path.exists() { debug!("No configuration exists"); - write(&config_path, include_str!("../config.example.toml")).map_err(|e| { + write(&config_path, EXAMPLE_CONFIG).map_err(|e| { debug!( "Unable to write the example configuration file to {}: {}. Using blank config.", config_path.display(), @@ -275,6 +277,10 @@ pub struct CommandLineArgs { #[structopt(long = "edit-config")] edit_config: bool, + /// Show config reference + #[structopt(long = "config-reference")] + show_config_reference: bool, + /// Run inside tmux #[structopt(short = "t", long = "tmux")] run_in_tmux: bool, @@ -324,6 +330,10 @@ impl CommandLineArgs { pub fn edit_config(&self) -> bool { self.edit_config } + + pub fn show_config_reference(&self) -> bool { + self.show_config_reference + } } /// Represents the application configuration diff --git a/src/main.rs b/src/main.rs index c56f0628..f92c13a0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,6 +38,11 @@ fn run() -> Result<()> { return Ok(()); }; + if opt.show_config_reference() { + print!("{}", crate::config::EXAMPLE_CONFIG); + return Ok(()); + } + let config = Config::load(&base_dirs, opt)?; terminal::set_title(config.set_title()); terminal::set_desktop_notifications(config.notify_each_step());