Skip to content
This repository has been archived by the owner on Jun 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #118 from Andrew15-5/rename-global-config-file
Browse files Browse the repository at this point in the history
fix(global config): renamed `default-config` to `typstfmt`
  • Loading branch information
astrale-sharp authored Oct 31, 2023
2 parents 023abc3 + 31ce52b commit 029c719
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use typstfmt_lib::{format, Config};

const VERSION: &str = env!("TYPSTFMT_VERSION");
const CONFIG_FILE_NAME: &str = "typstfmt.toml";
/// 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...]
Expand Down Expand Up @@ -153,7 +155,7 @@ fn main() -> Result<(), lexopt::Error> {
return Ok(());
}
Long("get-global-config-path") => {
let config_path = confy::get_configuration_file_path("typstfmt", None)
let config_path = 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(());
Expand Down Expand Up @@ -219,9 +221,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("typstfmt", None)
let config_path = confy::get_configuration_file_path(APP_NAME, APP_NAME)
.unwrap_or_else(|e| panic!("Error loading global configuration file: {e}"));
confy::load("typstfmt", None).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()
Expand Down

0 comments on commit 029c719

Please sign in to comment.