migrate -> update
This commit is contained in:
parent
40358b5d4d
commit
055ee2ca64
5 changed files with 14 additions and 14 deletions
|
@ -62,12 +62,12 @@ If you want to use this in the host network, you should use `host` as the networ
|
||||||
|
|
||||||
Please make sure to `cd` to the Firefish local repository before running these commands.
|
Please make sure to `cd` to the Firefish local repository before running these commands.
|
||||||
|
|
||||||
### Migrate the config files
|
### Update the config files
|
||||||
|
|
||||||
[The admin note](https://firefish.dev/firefish/firefish/-/blob/main/docs/notice-for-admins.md) may tell you that you need to update the config files. In such a case, please execute the following command.
|
[The admin note](https://firefish.dev/firefish/firefish/-/blob/main/docs/notice-for-admins.md) may tell you that you need to update the config files. In such a case, please execute the following command.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
fishctl config migrate
|
fishctl config update
|
||||||
```
|
```
|
||||||
|
|
||||||
### Validate the config files
|
### Validate the config files
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! `config` subcommand
|
//! `config` subcommand
|
||||||
|
|
||||||
mod migrate;
|
mod update;
|
||||||
mod validate;
|
mod validate;
|
||||||
|
|
||||||
use crate::config::{Revision, CLIENT_CONFIG_PATH, OLD_CONFIG_PATH, SERVER_CONFIG_PATH};
|
use crate::config::{Revision, CLIENT_CONFIG_PATH, OLD_CONFIG_PATH, SERVER_CONFIG_PATH};
|
||||||
|
@ -10,8 +10,8 @@ use std::{fs, io::Read, path::Path};
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub(crate) enum Commands {
|
pub(crate) enum Commands {
|
||||||
/// Convert an old config file into the new format
|
/// Convert old config files to the new format
|
||||||
Migrate { revision: Option<Revision> },
|
Update { revision: Option<Revision> },
|
||||||
/// Validate the config file
|
/// Validate the config file
|
||||||
Validate,
|
Validate,
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ pub(crate) enum Commands {
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub(crate) enum Error {
|
pub(crate) enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Migrate(#[from] migrate::MigrationError),
|
Update(#[from] update::UpdateError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Validate(#[from] validate::ValidationError),
|
Validate(#[from] validate::ValidationError),
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ fn next_revision() -> Result<Option<Revision>, RevisionCheckError> {
|
||||||
|
|
||||||
pub(crate) async fn run(command: Commands) -> Result<(), Error> {
|
pub(crate) async fn run(command: Commands) -> Result<(), Error> {
|
||||||
match command {
|
match command {
|
||||||
Commands::Migrate { revision } => migrate::run(revision).await?,
|
Commands::Update { revision } => update::run(revision).await?,
|
||||||
Commands::Validate => validate::run()?,
|
Commands::Validate => validate::run()?,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! `config migrate` subcommand
|
//! `config update` subcommand
|
||||||
|
|
||||||
mod v20240701;
|
mod v20240701;
|
||||||
|
|
||||||
|
@ -8,14 +8,14 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub(crate) enum MigrationError {
|
pub(crate) enum UpdateError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
UnknownRevision(#[from] RevisionCheckError),
|
UnknownRevision(#[from] RevisionCheckError),
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
V20240701(#[from] v20240701::Error),
|
V20240701(#[from] v20240701::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn update_to_latest() -> Result<(), MigrationError> {
|
async fn update_to_latest() -> Result<(), UpdateError> {
|
||||||
if next_revision()?.is_none() {
|
if next_revision()?.is_none() {
|
||||||
println!("Your config files are already up-to-date! (as of this fishctl release)");
|
println!("Your config files are already up-to-date! (as of this fishctl release)");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -27,14 +27,14 @@ async fn update_to_latest() -> Result<(), MigrationError> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run_impl(revision: Revision) -> Result<(), MigrationError> {
|
async fn run_impl(revision: Revision) -> Result<(), UpdateError> {
|
||||||
match revision {
|
match revision {
|
||||||
Revision::V20240701 => v20240701::run().await?,
|
Revision::V20240701 => v20240701::run().await?,
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) async fn run(revision: Option<Revision>) -> Result<(), MigrationError> {
|
pub(super) async fn run(revision: Option<Revision>) -> Result<(), UpdateError> {
|
||||||
match revision {
|
match revision {
|
||||||
Some(revision) => run_impl(revision).await,
|
Some(revision) => run_impl(revision).await,
|
||||||
None => update_to_latest().await,
|
None => update_to_latest().await,
|
|
@ -1,4 +1,4 @@
|
||||||
//! `config migrate 20240701` subcommand
|
//! `config update 20240701` subcommand
|
||||||
//! <https://firefish.dev/firefish/firefish/-/issues/10947>
|
//! <https://firefish.dev/firefish/firefish/-/issues/10947>
|
||||||
|
|
||||||
use crate::config::{
|
use crate::config::{
|
|
@ -31,7 +31,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 migrate</>` 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue