1use anyhow::Result;
3use opt::{Command, MigrateCommand};
4
5mod migrate;
6mod migrator;
7mod model;
8mod opt;
9
10pub use opt::Opt;
11
12pub async fn run(opt: Opt) -> Result<()> {
14 match opt.command {
15 Command::Migrate(migrate) => match migrate.command {
16 MigrateCommand::Add {
17 source,
18 description,
19 } => migrate::add(&source, &description).await?,
20 MigrateCommand::Init { connect_opts } => migrate::init(connect_opts).await?,
21 MigrateCommand::Run {
22 source,
23 next,
24 connect_opts,
25 } => migrate::run(&source, connect_opts, next).await?,
26 MigrateCommand::Revert {
27 source,
28 connect_opts,
29 } => migrate::revert(&source, connect_opts).await?,
30 MigrateCommand::Info { .. } => {
31 println!("TODO: implement info command");
32 }
33 },
34 Command::Completions { shell } => {
35 use std::io;
36
37 use clap::CommandFactory;
38 use clap_complete::generate;
39
40 generate(shell, &mut Command::command(), "scyllax", &mut io::stdout());
41 }
42 };
43
44 Ok(())
45}