From 679e0af6002983b7314b013b3af6d07e0cfb4799 Mon Sep 17 00:00:00 2001 From: Kiril Kovachev Date: Thu, 8 May 2025 00:39:31 +0100 Subject: [PATCH] refactor: Use constant to represent template for generated config file --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ac63d10..5458034 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use formatx::formatx; use clap::{Parser, Subcommand}; use mwbot::parsoid::WikiMultinode; +const CONFIG_TEMPLATE_PATH: &'static str = "mwbot.toml"; const BOT_CONFIG_PATH: &'static str = "~/.config/mwbot.toml"; #[derive(Parser)] @@ -41,7 +42,7 @@ enum Action { } fn setup(args: SetupArgs) -> Result<(), std::io::Error> { - if let Ok(config_template) = std::fs::read_to_string("mwbot.toml") { + if let Ok(config_template) = std::fs::read_to_string(CONFIG_TEMPLATE_PATH) { let filled_in_config = formatx!(config_template, args.api_url, args.rest_url, args.username, args.botpassword, args.oauth2_token).unwrap(); std::fs::write(shellexpand::tilde(BOT_CONFIG_PATH).into_owned(), filled_in_config).unwrap(); Ok(())