diff --git a/CHANGELOG.md b/CHANGELOG.md index fd0c4faa..1fbb86d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ This changelog documents the changes between release versions. ## [Unreleased] - Fix incorrect order of results for query requests with more than 10 variable sets (#37) - In the CLI update command, don't overwrite schema files that haven't changed ([#49](https://github.com/hasura/ndc-mongodb/pull/49/files)) +- In the CLI update command, if the database URI is not provided the error message now mentions the correct environment variable to use (`MONGODB_DATABASE_URI`) ([#50](https://github.com/hasura/ndc-mongodb/pull/50)) ## [0.0.4] - 2024-04-12 - Queries that attempt to compare a column to a column in the query root table, or a related table, will now fail instead of giving the incorrect result ([#22](https://github.com/hasura/ndc-mongodb/pull/22)) diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index 2c4b4af3..9b1752e4 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -7,7 +7,7 @@ use anyhow::anyhow; use std::env; use std::path::PathBuf; -use clap::Parser; +use clap::{Parser, ValueHint}; use mongodb_agent_common::state::{try_init_state_from_uri, DATABASE_URI_ENV_VAR}; use mongodb_cli_plugin::{run, Command, Context}; @@ -18,17 +18,18 @@ pub struct Args { #[arg( long = "context-path", env = "HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH", - value_name = "DIRECTORY" + value_name = "DIRECTORY", + value_hint = ValueHint::DirPath )] pub context_path: Option, #[arg( long = "connection-uri", env = DATABASE_URI_ENV_VAR, - required = true, - value_name = "URI" + value_name = "URI", + value_hint = ValueHint::Url )] - pub connection_uri: String, + pub connection_uri: Option, /// The command to invoke. #[command(subcommand)] @@ -45,7 +46,11 @@ pub async fn main() -> anyhow::Result<()> { Some(path) => path, None => env::current_dir()?, }; - let connector_state = try_init_state_from_uri(&args.connection_uri) + let connection_uri = args.connection_uri.ok_or(anyhow!( + "Missing environment variable {}", + DATABASE_URI_ENV_VAR + ))?; + let connector_state = try_init_state_from_uri(&connection_uri) .await .map_err(|e| anyhow!("Error initializing MongoDB state {}", e))?; let context = Context {