use clap::Parser; use container::Config; use container::start_attached; use container::db::DBInfo; /// Command line arguments #[derive(Parser, Debug)] #[command(author, version, about, long_about = None)] struct Args { /// Database type to use: 'postgres' or 'sqlite'. Can also be set with DB_TYPE env var. #[arg(long, default_value = "sqlite", env = "DB_TYPE")] db_type: String, } #[tokio::main] async fn main() { // Parse command line arguments and environment variables let args = Args::parse(); println!("Starting container with database type: {}", args.db_type); let db_config = match args.db_type.to_lowercase().as_str() { "postgres" | "pg" | "pgsql" => { use container::db::postgresql::PostgreSQLContainer; println!("Using PostgreSQL database"); PostgreSQLContainer::new(None) .await .get_db_container_config_info() .await } "sqlite" | "sql" => { println!("Using SQLite database"); use container::db::sqlite::SQLiteContainer; SQLiteContainer::new(None) .await .get_db_container_config_info() .await } other => { eprintln!("Unknown db_type: {}. Use 'postgres' or 'sqlite'", other); std::process::exit(1); } }; println!("Database configuration obtained."); let config = Config { database: db_config, }; println!("Starting container..."); start_attached(&config).await; println!("Container stopped. Exiting..."); }