Rename migrate command to tidy

It now does more than plain data dir migration. I'm not yet sure though
when tidying will be executed during normal operations. During app
startup sounds appropriate, maybe even at the end of open_and_migrate.
This commit is contained in:
Joscha 2025-04-29 01:36:38 +02:00
parent 3a3a2de8dc
commit b0ea87dbd6
2 changed files with 6 additions and 5 deletions

View file

@ -2,20 +2,20 @@ use clap::Parser;
use crate::Environment; use crate::Environment;
mod migrate;
mod status; mod status;
mod tidy;
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
pub enum Command { pub enum Command {
Migrate(migrate::Command),
Status(status::Command), Status(status::Command),
Tidy(tidy::Command),
} }
impl Command { impl Command {
pub fn run(self, env: &Environment) -> anyhow::Result<()> { pub fn run(self, env: &Environment) -> anyhow::Result<()> {
match self { match self {
Self::Migrate(command) => command.run(env),
Self::Status(command) => command.run(env), Self::Status(command) => command.run(env),
Self::Tidy(command) => command.run(env),
} }
} }
} }

View file

@ -2,13 +2,14 @@ use clap::Parser;
use crate::Environment; use crate::Environment;
/// Create or migrate the data dir, if necessary. /// Perform data dir maintenance.
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
pub struct Command {} pub struct Command {}
impl Command { impl Command {
pub fn run(self, env: &Environment) -> anyhow::Result<()> { pub fn run(self, env: &Environment) -> anyhow::Result<()> {
gdn::data::open_and_migrate(env.data_dir.clone())?; let data = gdn::data::open_and_migrate(env.data_dir.clone())?;
gdn::data::tidy(&data)?;
Ok(()) Ok(())
} }
} }