Skip to content

Commit bb33a29

Browse files
xpeDavid James
and
David James
authored
Fix issue #1431 (#1432)
Why: dotenv() must execute before clap's get_matches() Co-authored-by: David James <davidcjames@gmail.com>
1 parent efd08cc commit bb33a29

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

sqlx-cli/src/bin/cargo-sqlx.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use clap::{crate_version, AppSettings, FromArgMatches, IntoApp};
22
use console::style;
3+
use dotenv::dotenv;
34
use sqlx_cli::Opt;
45
use std::{env, process};
56

@@ -9,6 +10,7 @@ async fn main() {
910
// so we want to notch out that superfluous "sqlx"
1011
let args = env::args_os().skip(2);
1112

13+
dotenv().ok();
1214
let matches = Opt::into_app()
1315
.version(crate_version!())
1416
.bin_name("cargo sqlx")

sqlx-cli/src/bin/sqlx.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
use clap::{crate_version, FromArgMatches, IntoApp};
22
use console::style;
3+
use dotenv::dotenv;
34
use sqlx_cli::Opt;
45

56
#[tokio::main]
67
async fn main() {
8+
dotenv().ok();
79
let matches = Opt::into_app().version(crate_version!()).get_matches();
810

911
// no special handling here

sqlx-cli/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use anyhow::Result;
2-
use dotenv::dotenv;
32

43
use crate::opt::{Command, DatabaseCommand, MigrateCommand};
54

@@ -13,8 +12,6 @@ mod prepare;
1312
pub use crate::opt::Opt;
1413

1514
pub async fn run(opt: Opt) -> Result<()> {
16-
dotenv().ok();
17-
1815
match opt.command {
1916
Command::Migrate(migrate) => match migrate.command {
2017
MigrateCommand::Add {

0 commit comments

Comments
 (0)