//! `config update` subcommand mod v20240701; use crate::{ command::config::{next_revision, RevisionCheckError}, config::Revision, }; #[derive(thiserror::Error, Debug)] pub(crate) enum UpdateError { #[error(transparent)] UnknownRevision(#[from] RevisionCheckError), #[error(transparent)] V20240701(#[from] v20240701::Error), } async fn update_to_latest() -> Result<(), UpdateError> { if next_revision()?.is_none() { println!("Your config files are already up-to-date! (as of this fishctl release)"); return Ok(()); } while let Some(next_revision) = next_revision()? { run_impl(next_revision).await?; } Ok(()) } async fn run_impl(revision: Revision) -> Result<(), UpdateError> { match revision { Revision::V20240701 => v20240701::run().await?, } Ok(()) } pub(super) async fn run(revision: Option) -> Result<(), UpdateError> { match revision { Some(revision) => run_impl(revision).await, None => update_to_latest().await, } }