Skip to content

Commit 30bc4ef

Browse files
committed
feat(databases run): accept group-positional <id>, mirroring sandbox run
1 parent eb2bbf0 commit 30bc4ef

1 file changed

Lines changed: 29 additions & 17 deletions

File tree

src/main.rs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,31 @@ fn main() {
391391
command,
392392
} => {
393393
let workspace_id = resolve_workspace(workspace_id);
394-
if let Some(name_or_id) = name_or_id {
394+
// `databases <id> run ...` should mint a token for <id>, not
395+
// short to `show`. Route Run before the name_or_id show-shorthand;
396+
// --database on the subcommand takes precedence over the group
397+
// positional. Other subcommands keep the existing semantics: a
398+
// group-level name_or_id is treated as a `show` shorthand.
399+
if let Some(DatabasesCommands::Run {
400+
database,
401+
description,
402+
schema,
403+
tables,
404+
expires_at,
405+
cmd,
406+
}) = command
407+
{
408+
let db = database.as_deref().or(name_or_id.as_deref());
409+
databases::run(
410+
db,
411+
&workspace_id,
412+
description.as_deref(),
413+
&schema,
414+
&tables,
415+
expires_at.as_deref(),
416+
&cmd,
417+
);
418+
} else if let Some(name_or_id) = name_or_id {
395419
databases::get(&workspace_id, &name_or_id, &output);
396420
} else {
397421
match command {
@@ -438,22 +462,6 @@ fn main() {
438462
upload_id.as_deref(),
439463
)
440464
}
441-
Some(DatabasesCommands::Run {
442-
database,
443-
description,
444-
schema,
445-
tables,
446-
expires_at,
447-
cmd,
448-
}) => databases::run(
449-
database.as_deref(),
450-
&workspace_id,
451-
description.as_deref(),
452-
&schema,
453-
&tables,
454-
expires_at.as_deref(),
455-
&cmd,
456-
),
457465
Some(DatabasesCommands::Tables { database, command }) => match command {
458466
Some(DatabaseTablesCommands::List {
459467
database: db_flag,
@@ -512,6 +520,10 @@ fn main() {
512520
}
513521
}
514522
},
523+
Some(DatabasesCommands::Run { .. }) => {
524+
// Handled by the Run-first if-let above.
525+
unreachable!("Run handled before name_or_id shorthand");
526+
}
515527
None => {
516528
use clap::CommandFactory;
517529
let mut cmd = Cli::command();

0 commit comments

Comments
 (0)