From 701cf746939f6180050dd6da95db756ad4f38612 Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 21 Jun 2024 13:16:16 +0900 Subject: [PATCH] WIP --- README.md | 4 +++- src/command/config.rs | 4 ++-- src/command/config/update/v1.rs | 6 +++--- src/config/client.rs | 2 +- src/config/mod.rs | 3 +-- src/config/server.rs | 2 +- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 80ca364..17f9290 100644 --- a/README.md +++ b/README.md @@ -76,8 +76,10 @@ fishctl config update ### Validate the config files -To validate the config files, run the following command. Note that this only performs a formal validation and does not check that the settings are appropriate. For example, this command does not check if the database password is correct. +Execute the following command to validate the config files. ```sh fishctl config validate ``` + +Note that this only performs a formal validation and does not check that the settings are appropriate. For example, this command does not check if the database password is correct. diff --git a/src/command/config.rs b/src/command/config.rs index 3139ce3..881a740 100644 --- a/src/command/config.rs +++ b/src/command/config.rs @@ -3,7 +3,7 @@ mod update; mod validate; -use crate::config::{Revision, CLIENT_CONFIG_PATH, OLD_CONFIG_PATH, SERVER_CONFIG_PATH}; +use crate::config::{Revision, CLIENT_CONFIG_PATH, SERVER_CONFIG_PATH}; use clap::Subcommand; use serde::Deserialize; use std::{ @@ -68,7 +68,7 @@ where } fn current_revision() -> Result { - let old_config_exists = Path::new(OLD_CONFIG_PATH).is_file(); + let old_config_exists = Path::new(".config/default.yml").is_file(); let server_config_exists = Path::new(SERVER_CONFIG_PATH).is_file(); let client_config_exists = Path::new(CLIENT_CONFIG_PATH).is_file(); diff --git a/src/command/config/update/v1.rs b/src/command/config/update/v1.rs index 7f95915..54c95a9 100644 --- a/src/command/config/update/v1.rs +++ b/src/command/config/update/v1.rs @@ -3,7 +3,7 @@ use crate::{ command::config::{read_file_as_string, ReadError}, - config::{client, server, Revision, CLIENT_CONFIG_PATH, OLD_CONFIG_PATH, SERVER_CONFIG_PATH}, + config::{client, server, Revision, CLIENT_CONFIG_PATH, SERVER_CONFIG_PATH}, }; use color_print::cprintln; use sqlx::{postgres::PgConnectOptions, ConnectOptions}; @@ -19,7 +19,7 @@ use yaml_rust::{Yaml, YamlLoader}; /// Errors that can happen in `config update v1` subcommand #[derive(thiserror::Error, Debug)] pub(crate) enum Error { - #[error("failed to parse the old config file ({})", OLD_CONFIG_PATH)] + #[error("failed to parse the old config file (.config/default.yml)")] ReadYaml(#[from] ReadYamlConfigError), #[error(transparent)] WriteToml(#[from] WriteTomlConfigError), @@ -58,7 +58,7 @@ pub(crate) enum WriteTomlConfigError { } fn read_default_yml() -> Result, ReadYamlConfigError> { - let content = YamlLoader::load_from_str(&read_file_as_string(OLD_CONFIG_PATH)?)?; + let content = YamlLoader::load_from_str(&read_file_as_string(".config/default.yml")?)?; if content.is_empty() { return Err(ReadYamlConfigError::InvalidConfig( diff --git a/src/config/client.rs b/src/config/client.rs index aba7ca7..b4ddd7c 100644 --- a/src/config/client.rs +++ b/src/config/client.rs @@ -5,7 +5,7 @@ // Optional values are handled in the main Firefish program, and this tool // does not take care of it. -use super::{ensure_latest_revision, Revision}; +use crate::config::{ensure_latest_revision, Revision}; use serde::{Deserialize, Serialize}; use validator::{Validate, ValidationError}; diff --git a/src/config/mod.rs b/src/config/mod.rs index 6e93dad..3438ff8 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -10,7 +10,6 @@ use validator::ValidationError; pub(crate) const SERVER_CONFIG_PATH: &str = "config/server.toml"; pub(crate) const CLIENT_CONFIG_PATH: &str = "config/client.toml"; -pub(crate) const OLD_CONFIG_PATH: &str = ".config/default.yml"; #[derive(Deserialize_repr, Serialize_repr, PartialEq, Clone, ValueEnum, Sequence, Debug)] #[clap(rename_all = "lowercase")] @@ -19,7 +18,7 @@ pub enum Revision { #[clap(skip)] /// Misskey-style config (`.config/default.yml`) V0, - /// The first revision number for `config/{server,client}.toml` + /// The first revision for `config/{server,client}.toml` V1, } diff --git a/src/config/server.rs b/src/config/server.rs index 3783146..39820ac 100644 --- a/src/config/server.rs +++ b/src/config/server.rs @@ -5,7 +5,7 @@ // Optional values are handled in the main Firefish program, and this tool // does not take care of it. -use super::{ensure_latest_revision, Revision}; +use crate::config::{ensure_latest_revision, Revision}; use serde::{Deserialize, Serialize}; use validator::Validate;