use clap::Clap;
#[derive(Clap, Debug)]
pub struct Opt {
#[clap(subcommand)]
pub command: Command,
#[clap(short = 'D', long)]
pub database_url: Option<String>,
}
#[derive(Clap, Debug)]
pub enum Command {
#[clap(alias = "db")]
Database(DatabaseOpt),
#[clap(alias = "prep")]
Prepare {
#[clap(long)]
check: bool,
#[clap(long)]
merged: bool,
#[clap(last = true)]
args: Vec<String>,
},
#[clap(alias = "mig")]
Migrate(MigrateOpt),
}
#[derive(Clap, Debug)]
pub struct DatabaseOpt {
#[clap(subcommand)]
pub command: DatabaseCommand,
}
#[derive(Clap, Debug)]
pub enum DatabaseCommand {
Create,
Drop {
#[clap(short)]
yes: bool,
},
Reset {
#[clap(short)]
yes: bool,
#[clap(long, default_value = "migrations")]
source: String,
},
Setup {
#[clap(long, default_value = "migrations")]
source: String,
},
}
#[derive(Clap, Debug)]
pub struct MigrateOpt {
#[clap(long, default_value = "migrations")]
pub source: String,
#[clap(subcommand)]
pub command: MigrateCommand,
}
#[derive(Clap, Debug)]
pub enum MigrateCommand {
Add {
description: String,
#[clap(short)]
reversible: bool,
},
Run {
#[clap(long)]
dry_run: bool,
#[clap(long)]
ignore_missing: bool,
},
Revert {
#[clap(long)]
dry_run: bool,
#[clap(long)]
ignore_missing: bool,
},
Info,
}