drizzle_cli/commands/harness.rs
1//! Shared command preamble helpers.
2//!
3//! Every database-touching command opens with the same multi-db header
4//! ("Database: foo" when the config has multiple `[databases.*]` blocks).
5//! Concentrating that here removes the repeated five-line block from each
6//! command body — they call [`print_db_header`] and move on.
7
8use crate::config::Config;
9use crate::output;
10
11/// Print the "Database: <name>" line when the config holds more than one
12/// database. No-op on single-database configs.
13pub fn print_db_header(config: &Config, db_name: Option<&str>) {
14 if !config.is_single_database() {
15 let name = db_name.unwrap_or("(default)");
16 println!(" {}: {}", output::label("Database"), name);
17 }
18}