mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-20 01:01:24 +01:00
wip: db convert command
This commit is contained in:
parent
b3d9cd5e9c
commit
0e3e5c10bf
5 changed files with 46 additions and 2 deletions
34
src/cli.rs
34
src/cli.rs
|
|
@ -7,8 +7,9 @@ use std::path::PathBuf;
|
|||
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
use crate::error;
|
||||
use crate::{config::DatabaseBackend, error};
|
||||
|
||||
mod db;
|
||||
mod serve;
|
||||
|
||||
/// Command line arguments
|
||||
|
|
@ -26,6 +27,10 @@ pub(crate) struct Args {
|
|||
pub(crate) enum Command {
|
||||
/// Run the server.
|
||||
Serve(ServeArgs),
|
||||
|
||||
/// Database utilities
|
||||
#[clap(subcommand)]
|
||||
Db(DbCommand),
|
||||
}
|
||||
|
||||
/// Wrapper for the `--config` arg.
|
||||
|
|
@ -57,10 +62,37 @@ pub(crate) struct ServeArgs {
|
|||
pub(crate) config: ConfigArg,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
pub(crate) enum DbCommand {
|
||||
/// Convert between database backends
|
||||
///
|
||||
/// Once this command successfully completes, copy or move the `media`
|
||||
/// directory from `IN_PATH` to `OUT_PATH` to complete the migration.
|
||||
Convert(DbConvert),
|
||||
}
|
||||
|
||||
#[derive(clap::Args)]
|
||||
pub(crate) struct DbConvert {
|
||||
/// The backend to convert from
|
||||
in_backend: DatabaseBackend,
|
||||
|
||||
/// The backend to convert to
|
||||
out_backend: DatabaseBackend,
|
||||
|
||||
/// Path to the database to read
|
||||
in_path: PathBuf,
|
||||
|
||||
/// Path to write the new database
|
||||
out_path: PathBuf,
|
||||
}
|
||||
|
||||
impl Args {
|
||||
pub(crate) async fn run(self) -> Result<(), error::Main> {
|
||||
match self.command {
|
||||
Command::Serve(args) => serve::run(args).await?,
|
||||
Command::Db(DbCommand::Convert(args)) => {
|
||||
db::convert::run(args).await?
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue