mirror of
https://github.com/launchbadge/sqlx.git
synced 2025-12-26 10:09:50 +00:00
Why: dotenv() must execute before clap's get_matches() Co-authored-by: David James <davidcjames@gmail.com>
This commit is contained in:
parent
efd08cc4b3
commit
bb33a296cb
@ -1,5 +1,6 @@
|
||||
use clap::{crate_version, AppSettings, FromArgMatches, IntoApp};
|
||||
use console::style;
|
||||
use dotenv::dotenv;
|
||||
use sqlx_cli::Opt;
|
||||
use std::{env, process};
|
||||
|
||||
@ -9,6 +10,7 @@ async fn main() {
|
||||
// so we want to notch out that superfluous "sqlx"
|
||||
let args = env::args_os().skip(2);
|
||||
|
||||
dotenv().ok();
|
||||
let matches = Opt::into_app()
|
||||
.version(crate_version!())
|
||||
.bin_name("cargo sqlx")
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
use clap::{crate_version, FromArgMatches, IntoApp};
|
||||
use console::style;
|
||||
use dotenv::dotenv;
|
||||
use sqlx_cli::Opt;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
dotenv().ok();
|
||||
let matches = Opt::into_app().version(crate_version!()).get_matches();
|
||||
|
||||
// no special handling here
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use anyhow::Result;
|
||||
use dotenv::dotenv;
|
||||
|
||||
use crate::opt::{Command, DatabaseCommand, MigrateCommand};
|
||||
|
||||
@ -13,8 +12,6 @@ mod prepare;
|
||||
pub use crate::opt::Opt;
|
||||
|
||||
pub async fn run(opt: Opt) -> Result<()> {
|
||||
dotenv().ok();
|
||||
|
||||
match opt.command {
|
||||
Command::Migrate(migrate) => match migrate.command {
|
||||
MigrateCommand::Add {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user