Skip to content

Commit 5707cbc

Browse files
committed
fmt: apply rustfmt
1 parent 5453572 commit 5707cbc

4 files changed

Lines changed: 44 additions & 31 deletions

File tree

‎src/commands/databases.rs‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -912,10 +912,7 @@ pub fn get(workspace_id: &str, id_or_name: &str, format: &str) {
912912
println!(
913913
"{}{}",
914914
label("sql_prefix:"),
915-
format!(
916-
"{catalog}.{{schema}}.{{table}}"
917-
)
918-
.green()
915+
format!("{catalog}.{{schema}}.{{table}}").green()
919916
);
920917
if !db.attachments.is_empty() {
921918
println!("{}({})", label("attached catalogs:"), db.attachments.len());
@@ -1383,8 +1380,14 @@ pub fn tables_list(
13831380
.as_deref()
13841381
.or(db.name.as_deref())
13851382
.unwrap_or("default");
1386-
let (tables, has_more, next_cursor) =
1387-
collect_tables(&api, &db.default_connection_id, schema, table, limit, cursor);
1383+
let (tables, has_more, next_cursor) = collect_tables(
1384+
&api,
1385+
&db.default_connection_id,
1386+
schema,
1387+
table,
1388+
limit,
1389+
cursor,
1390+
);
13881391

13891392
let rows = table_rows(catalog, tables);
13901393

@@ -1526,7 +1529,8 @@ pub fn tables_load(
15261529
// The table wasn't declared at create time. Collect existing tables so
15271530
// they are re-declared in the replacement database, then delete and
15281531
// recreate with all tables (including the new one) declared.
1529-
let (existing, _, _) = collect_tables(&api, &db.default_connection_id, None, None, None, None);
1532+
let (existing, _, _) =
1533+
collect_tables(&api, &db.default_connection_id, None, None, None, None);
15301534
let mut all_tables: Vec<String> = existing
15311535
.iter()
15321536
.map(|t| format!("{}.{}", t.schema, t.table))

‎src/commands/indexes.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1349,15 +1349,18 @@ mod tests {
13491349
}
13501350

13511351
fn parse(args: &[&str]) -> Result<IndexesCommands, clap::Error> {
1352-
Wrapper::try_parse_from(std::iter::once("t").chain(args.iter().copied()))
1353-
.map(|w| w.cmd)
1352+
Wrapper::try_parse_from(std::iter::once("t").chain(args.iter().copied())).map(|w| w.cmd)
13541353
}
13551354

13561355
#[test]
13571356
fn list_parses_with_no_flags() {
13581357
assert!(matches!(
13591358
parse(&["list"]).unwrap(),
1360-
IndexesCommands::List { schema: None, table: None, .. }
1359+
IndexesCommands::List {
1360+
schema: None,
1361+
table: None,
1362+
..
1363+
}
13611364
));
13621365
}
13631366

‎src/commands/tables.rs‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,27 @@ pub fn show(workspace_id: &str, table_ref: &str, format: &str) {
164164
);
165165
std::process::exit(1);
166166
});
167-
let db = crate::commands::databases::get_database(&api, &db_id)
168-
.unwrap_or_else(|e| e.exit());
167+
let db =
168+
crate::commands::databases::get_database(&api, &db_id).unwrap_or_else(|e| e.exit());
169169
let catalog = db
170170
.default_catalog
171171
.unwrap_or_else(|| db.name.unwrap_or_else(|| "default".to_string()));
172-
(db.default_connection_id, catalog, schema.to_string(), table.to_string())
172+
(
173+
db.default_connection_id,
174+
catalog,
175+
schema.to_string(),
176+
table.to_string(),
177+
)
173178
}
174179
[catalog, schema, table] => {
175180
// Three-part: resolve the catalog/name as a database or connection.
176-
let conn_id =
177-
crate::commands::connections::resolve_connection_id(&api, catalog);
178-
(conn_id, catalog.to_string(), schema.to_string(), table.to_string())
181+
let conn_id = crate::commands::connections::resolve_connection_id(&api, catalog);
182+
(
183+
conn_id,
184+
catalog.to_string(),
185+
schema.to_string(),
186+
table.to_string(),
187+
)
179188
}
180189
_ => {
181190
use crossterm::style::Stylize;

‎src/main.rs‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -535,16 +535,14 @@ fn main() {
535535
table,
536536
output,
537537
} => {
538-
let connection_id = crate::config::load_current_database(
539-
"default",
540-
&workspace_id,
541-
)
542-
.and_then(|db_id| {
543-
let api = sdk::Api::new(Some(&workspace_id));
544-
crate::commands::databases::get_database(&api, &db_id)
545-
.ok()
546-
.map(|db| db.default_connection_id)
547-
});
538+
let connection_id =
539+
crate::config::load_current_database("default", &workspace_id)
540+
.and_then(|db_id| {
541+
let api = sdk::Api::new(Some(&workspace_id));
542+
crate::commands::databases::get_database(&api, &db_id)
543+
.ok()
544+
.map(|db| db.default_connection_id)
545+
});
548546
indexes::list(
549547
&workspace_id,
550548
connection_id.as_deref(),
@@ -708,17 +706,16 @@ fn main() {
708706
let api = sdk::Api::new(Some(&workspace_id));
709707
let db = crate::commands::databases::get_database(&api, &db_id)
710708
.unwrap_or_else(|e| e.exit());
711-
let catalog = db.default_catalog.unwrap_or_else(|| {
712-
db.name.unwrap_or_else(|| "default".to_string())
713-
});
709+
let catalog = db
710+
.default_catalog
711+
.unwrap_or_else(|| db.name.unwrap_or_else(|| "default".to_string()));
714712
(catalog, schema.to_string(), tbl.to_string())
715713
}
716714
_ => {
717715
use crossterm::style::Stylize;
718716
eprintln!(
719717
"{}",
720-
"error: --table must be 'schema.table' or 'catalog.schema.table'"
721-
.red()
718+
"error: --table must be 'schema.table' or 'catalog.schema.table'".red()
722719
);
723720
std::process::exit(1);
724721
}

0 commit comments

Comments
 (0)