diff --git a/crates/llm/src/bin/ullm.rs b/crates/llm/src/bin/ullm.rs index 3b68ba2a4..3c9701446 100644 --- a/crates/llm/src/bin/ullm.rs +++ b/crates/llm/src/bin/ullm.rs @@ -9,6 +9,10 @@ use llm::generate::{self, GenerateParams}; #[derive(Parser)] #[command(name = "ullm")] struct Cli { + /// Skip loading .env file + #[arg(long, global = true)] + no_dotenv: bool, + #[command(subcommand)] command: Command, } @@ -217,8 +221,10 @@ async fn run_prompt(args: PromptArgs) -> Result<()> { #[tokio::main] async fn main() -> Result<()> { - dotenvy::dotenv().ok(); let cli = Cli::parse(); + if !cli.no_dotenv { + dotenvy::dotenv().ok(); + } match cli.command { Command::Prompt { @@ -367,10 +373,8 @@ mod tests { fn prompt_reads_from_stdin() { // This test verifies stdin is read, but will fail at the API call stage // since no API key is set. The error should NOT be "no prompt provided". - // env_clear() prevents .env loading from triggering real API calls. let result = ullm() - .env_clear() - .args(["prompt", "--no-stream", "-m", "test-model"]) + .args(["--no-dotenv", "prompt", "--no-stream", "-m", "test-model"]) .write_stdin("hello from stdin") .assert() .failure(); @@ -383,10 +387,8 @@ mod tests { #[test] fn prompt_concatenates_stdin_and_arg() { // Same as above — verifies it doesn't error on "no prompt" - // env_clear() prevents .env loading from triggering real API calls. let result = ullm() - .env_clear() - .args(["prompt", "--no-stream", "-m", "test-model", "summarize this"]) + .args(["--no-dotenv", "prompt", "--no-stream", "-m", "test-model", "summarize this"]) .write_stdin("some input text") .assert() .failure();