rename revisions

This commit is contained in:
naskya 2024-06-21 06:49:10 +09:00
parent 55d43e1cf4
commit c6cfe89079
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
5 changed files with 13 additions and 15 deletions

View file

@ -56,7 +56,7 @@ fn next_revision() -> Result<Option<Revision>, RevisionCheckError> {
} }
if old_config_exists && !server_config_exists && !client_config_exists { if old_config_exists && !server_config_exists && !client_config_exists {
return Ok(Some(Revision::V20240701)); return Ok(Some(Revision::V1));
} }
#[derive(Deserialize)] #[derive(Deserialize)]
@ -83,7 +83,7 @@ fn next_revision() -> Result<Option<Revision>, RevisionCheckError> {
} }
let next_revision = match server_config_revision { let next_revision = match server_config_revision {
Revision::V20240701 => None, Revision::V1 => None,
}; };
Ok(next_revision) Ok(next_revision)

View file

@ -1,6 +1,6 @@
//! `config update` subcommand //! `config update` subcommand
mod v20240701; mod v1;
use crate::{ use crate::{
command::config::{next_revision, RevisionCheckError}, command::config::{next_revision, RevisionCheckError},
@ -12,7 +12,7 @@ pub(crate) enum UpdateError {
#[error(transparent)] #[error(transparent)]
UnknownRevision(#[from] RevisionCheckError), UnknownRevision(#[from] RevisionCheckError),
#[error(transparent)] #[error(transparent)]
V20240701(#[from] v20240701::Error), V1(#[from] v1::Error),
} }
async fn update_to_latest() -> Result<(), UpdateError> { 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> { async fn run_impl(revision: Revision) -> Result<(), UpdateError> {
match revision { match revision {
Revision::V20240701 => v20240701::run().await?, Revision::V1 => v1::run().await?,
} }
Ok(()) Ok(())
} }

View file

@ -1,4 +1,4 @@
//! `config update 20240701` subcommand //! `config update v1` subcommand
//! <https://firefish.dev/firefish/firefish/-/issues/10947> //! <https://firefish.dev/firefish/firefish/-/issues/10947>
use crate::config::{ use crate::config::{
@ -274,7 +274,7 @@ fn create_new_server_config(
}; };
let mut server_config = server::Config { let mut server_config = server::Config {
config_revision: Revision::V20240701, config_revision: Revision::V1,
info: Some(server::Info { info: Some(server::Info {
name: meta.name.to_owned(), name: meta.name.to_owned(),
description: meta.description.to_owned(), description: meta.description.to_owned(),
@ -395,7 +395,7 @@ fn create_new_server_config(
fn create_new_client_config(meta: Meta) -> Result<client::Config, Error> { fn create_new_client_config(meta: Meta) -> Result<client::Config, Error> {
let mut config = client::Config { let mut config = client::Config {
config_revision: Revision::V20240701, config_revision: Revision::V1,
theme: None, theme: None,
image: None, image: None,
pinned_links: None, pinned_links: None,
@ -432,7 +432,7 @@ fn create_new_client_config(meta: Meta) -> Result<client::Config, Error> {
} }
pub(super) async fn run() -> Result<(), Error> { 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?; let (default_yml, meta) = read_old_config().await?;

View file

@ -30,9 +30,7 @@ enum ReadError {
pub(super) fn run() -> Result<(), ValidationError> { pub(super) fn run() -> Result<(), ValidationError> {
if next_revision()?.is_some() { if next_revision()?.is_some() {
cprintln!( cprintln!("Please first run `<bold>fishctl config update</>` to update your config files.");
"Please first run `<bold>fishctl config update</>` to update your config files."
);
return Err(ValidationError::OutOfDate); return Err(ValidationError::OutOfDate);
} }

View file

@ -5,10 +5,10 @@ use clap::ValueEnum;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize, PartialEq, Clone, ValueEnum, Debug)] #[derive(Deserialize, Serialize, PartialEq, Clone, ValueEnum, Debug)]
#[clap(rename_all = "lowercase")]
pub enum Revision { pub enum Revision {
#[clap(name = "20240701")] #[serde(rename = "1")]
#[serde(rename = "20240701")] V1,
V20240701,
} }
pub const SERVER_CONFIG_PATH: &str = "config/server.toml"; pub const SERVER_CONFIG_PATH: &str = "config/server.toml";