From c6cfe890797bf6d97106d9172b657ea0c8e8428b Mon Sep 17 00:00:00 2001 From: naskya Date: Fri, 21 Jun 2024 06:49:10 +0900 Subject: [PATCH] rename revisions --- src/command/config.rs | 4 ++-- src/command/config/update.rs | 6 +++--- src/command/config/update/{v20240701.rs => v1.rs} | 8 ++++---- src/command/config/validate.rs | 4 +--- src/config/mod.rs | 6 +++--- 5 files changed, 13 insertions(+), 15 deletions(-) rename src/command/config/update/{v20240701.rs => v1.rs} (98%) diff --git a/src/command/config.rs b/src/command/config.rs index d5ae7fb..76d60ee 100644 --- a/src/command/config.rs +++ b/src/command/config.rs @@ -56,7 +56,7 @@ fn next_revision() -> Result, RevisionCheckError> { } if old_config_exists && !server_config_exists && !client_config_exists { - return Ok(Some(Revision::V20240701)); + return Ok(Some(Revision::V1)); } #[derive(Deserialize)] @@ -83,7 +83,7 @@ fn next_revision() -> Result, RevisionCheckError> { } let next_revision = match server_config_revision { - Revision::V20240701 => None, + Revision::V1 => None, }; Ok(next_revision) diff --git a/src/command/config/update.rs b/src/command/config/update.rs index 63d2e2e..5b7f0d0 100644 --- a/src/command/config/update.rs +++ b/src/command/config/update.rs @@ -1,6 +1,6 @@ //! `config update` subcommand -mod v20240701; +mod v1; use crate::{ command::config::{next_revision, RevisionCheckError}, @@ -12,7 +12,7 @@ pub(crate) enum UpdateError { #[error(transparent)] UnknownRevision(#[from] RevisionCheckError), #[error(transparent)] - V20240701(#[from] v20240701::Error), + V1(#[from] v1::Error), } async fn update_to_latest() -> Result<(), UpdateError> { @@ -29,7 +29,7 @@ async fn update_to_latest() -> Result<(), UpdateError> { async fn run_impl(revision: Revision) -> Result<(), UpdateError> { match revision { - Revision::V20240701 => v20240701::run().await?, + Revision::V1 => v1::run().await?, } Ok(()) } diff --git a/src/command/config/update/v20240701.rs b/src/command/config/update/v1.rs similarity index 98% rename from src/command/config/update/v20240701.rs rename to src/command/config/update/v1.rs index 8e6f87e..32baa28 100644 --- a/src/command/config/update/v20240701.rs +++ b/src/command/config/update/v1.rs @@ -1,4 +1,4 @@ -//! `config update 20240701` subcommand +//! `config update v1` subcommand //! use crate::config::{ @@ -274,7 +274,7 @@ fn create_new_server_config( }; let mut server_config = server::Config { - config_revision: Revision::V20240701, + config_revision: Revision::V1, info: Some(server::Info { name: meta.name.to_owned(), description: meta.description.to_owned(), @@ -395,7 +395,7 @@ fn create_new_server_config( fn create_new_client_config(meta: Meta) -> Result { let mut config = client::Config { - config_revision: Revision::V20240701, + config_revision: Revision::V1, theme: None, image: None, pinned_links: None, @@ -432,7 +432,7 @@ fn create_new_client_config(meta: Meta) -> Result { } pub(super) async fn run() -> Result<(), Error> { - println!("Updating the config revision to 20240701..."); + println!("Updating the config revision to 1..."); let (default_yml, meta) = read_old_config().await?; diff --git a/src/command/config/validate.rs b/src/command/config/validate.rs index d561c34..e97c4fb 100644 --- a/src/command/config/validate.rs +++ b/src/command/config/validate.rs @@ -30,9 +30,7 @@ enum ReadError { pub(super) fn run() -> Result<(), ValidationError> { if next_revision()?.is_some() { - cprintln!( - "Please first run `fishctl config update` to update your config files." - ); + cprintln!("Please first run `fishctl config update` to update your config files."); return Err(ValidationError::OutOfDate); } diff --git a/src/config/mod.rs b/src/config/mod.rs index b5a44f0..5fd590c 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -5,10 +5,10 @@ use clap::ValueEnum; use serde::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, PartialEq, Clone, ValueEnum, Debug)] +#[clap(rename_all = "lowercase")] pub enum Revision { - #[clap(name = "20240701")] - #[serde(rename = "20240701")] - V20240701, + #[serde(rename = "1")] + V1, } pub const SERVER_CONFIG_PATH: &str = "config/server.toml";