From cd115c65a6014a95fd4b3dadc2a7e2d2006e33fd Mon Sep 17 00:00:00 2001 From: Andrew Voynov Date: Tue, 31 Oct 2023 00:15:57 +0300 Subject: [PATCH] chore(global config): merged related `const`s Merged `CONFY_APP_NAME` and `GLOBAL_CONFIG_BASE_NAME` into `APP_NAME`. It is shorter and more meaningful. --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 01d559b..eb1960e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,8 +11,8 @@ use typstfmt_lib::{format, Config}; const VERSION: &str = env!("TYPSTFMT_VERSION"); const CONFIG_FILE_NAME: &str = "typstfmt.toml"; -const CONFY_APP_NAME: &str = "typstfmt"; -const GLOBAL_CONFIG_BASE_NAME: &str = "typstfmt"; +/// Note: used in [`confy`](https://crates.io/crates/confy) functions. +const APP_NAME: &str = "typstfmt"; const HELP: &str = r#"Format Typst code usage: typstfmt [options] [file...] @@ -157,7 +157,7 @@ fn main() -> Result<(), lexopt::Error> { } Long("get-global-config-path") => { let config_path = - confy::get_configuration_file_path(CONFY_APP_NAME, GLOBAL_CONFIG_BASE_NAME) + confy::get_configuration_file_path(APP_NAME, APP_NAME) .unwrap_or_else(|e| panic!("Error loading global configuration file: {e}")); println!("{}", config_path.display()); return Ok(()); @@ -224,9 +224,9 @@ fn main() -> Result<(), lexopt::Error> { Config::from_toml(&buf).unwrap_or_else(|e| panic!("Config file invalid: {e}.\nYou'll maybe have to delete it and use -C to create a default config file.")) } else { let config_path = - confy::get_configuration_file_path(CONFY_APP_NAME, GLOBAL_CONFIG_BASE_NAME) + confy::get_configuration_file_path(APP_NAME, APP_NAME) .unwrap_or_else(|e| panic!("Error loading global configuration file: {e}")); - confy::load(CONFY_APP_NAME, GLOBAL_CONFIG_BASE_NAME).unwrap_or_else(|e| { + confy::load(APP_NAME, APP_NAME).unwrap_or_else(|e| { panic!( "Error loading global configuration file at {}: {e}", config_path.display()