mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
Add --database-url to command line
This commit is contained in:
committed by
Austin Bonander
parent
dfb096eaa7
commit
2ec5ff06b0
@@ -15,8 +15,11 @@ pub use crate::opt::Opt;
|
||||
pub async fn run(opt: Opt) -> anyhow::Result<()> {
|
||||
dotenv().ok();
|
||||
|
||||
let database_url = env::var("DATABASE_URL")
|
||||
.map_err(|_| anyhow!("The DATABASE_URL environment variable must be set"))?;
|
||||
let database_url = match opt.database_url {
|
||||
Some(db_url) => db_url,
|
||||
None => env::var("DATABASE_URL")
|
||||
.map_err(|_| anyhow!("The DATABASE_URL environment variable must be set"))?,
|
||||
};
|
||||
|
||||
match opt.command {
|
||||
Command::Migrate(migrate) => match migrate.command {
|
||||
|
||||
@@ -4,6 +4,9 @@ use clap::Clap;
|
||||
pub struct Opt {
|
||||
#[clap(subcommand)]
|
||||
pub command: Command,
|
||||
|
||||
#[clap(short = "D", long)]
|
||||
pub database_url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clap, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user