Skip to content

Commit 905ebee

Browse files
committed
fix(databases): restore -d/--database on context, queries, results
The reorg re-parented `context`/`queries`/`results` under `databases` but the explicit database target regressed vs 0.26.0: - `databases context {list,show,pull,push}` had no way to target a database — active-database only. - `databases queries list` / `databases results {get,list}` rejected `-d` after the subcommand; the group-level `database` was only reachable before it (`databases queries -d X list`), not the expected `... list -d X`. Make the group `database` arg `global = true` on queries/results (the dispatch already threads it), and add a `-d/--database` (global) to `context` wired into its dispatch (explicit override, else the active database). Standardizes on `--database` (the reorg's convention) rather than the old `--database-id`. Verified: `context/queries/results list -d <db>` now byte-match the installed 0.26.0's `--database`/`--database-id` output.
1 parent 59b4e39 commit 905ebee

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎src/commands/databases.rs‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ pub enum DatabasesCommands {
196196

197197
/// Sync database context with local Markdown
198198
Context {
199+
/// Managed database to scope to (defaults to the current database)
200+
#[arg(long, short = 'd', global = true)]
201+
database: Option<String>,
202+
199203
#[command(subcommand)]
200204
command: crate::commands::context::ContextCommands,
201205
},
@@ -228,7 +232,7 @@ pub enum DatabasesCommands {
228232
id: Option<String>,
229233

230234
/// Managed database to scope to (defaults to the current database)
231-
#[arg(long, short = 'd')]
235+
#[arg(long, short = 'd', global = true)]
232236
database: Option<String>,
233237

234238
/// Output format
@@ -245,7 +249,7 @@ pub enum DatabasesCommands {
245249
result_id: Option<String>,
246250

247251
/// Managed database to scope to (defaults to the current database)
248-
#[arg(long, short = 'd')]
252+
#[arg(long, short = 'd', global = true)]
249253
database: Option<String>,
250254

251255
/// Output format

‎src/main.rs‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -408,15 +408,17 @@ fn main() {
408408
}
409409
}
410410
},
411-
Some(DatabasesCommands::Context { command }) => {
412-
let database_id =
413-
config::load_current_database("default", &workspace_id)
414-
.unwrap_or_else(|| {
415-
eprintln!(
416-
"error: no active database. Use 'hotdata databases use <id>' to set one."
417-
);
418-
std::process::exit(1);
419-
});
411+
Some(DatabasesCommands::Context { database, command }) => {
412+
let database_id = database
413+
.or_else(|| {
414+
config::load_current_database("default", &workspace_id)
415+
})
416+
.unwrap_or_else(|| {
417+
eprintln!(
418+
"error: no active database. Pass -d/--database <id> or set one with 'hotdata databases use <id>'."
419+
);
420+
std::process::exit(1);
421+
});
420422
match command {
421423
ContextCommands::List { output, prefix } => context::list(
422424
&workspace_id,

0 commit comments

Comments
 (0)