Skip to content

Commit

Permalink
Optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
fankaiLiu committed Oct 28, 2023
1 parent 1a488a4 commit ea89b95
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,36 @@ pub fn create_project(project: Project) -> Result<()> {
init_git(project_path)?;

success(t!("create_success", project_name = project_name).replace(r"\n", "\n"));
if config.db_conn_type == DbConnectionType::Sqlx
|| config.db_conn_type == DbConnectionType::SeaOrm
|| config.db_conn_type == DbConnectionType::Diesel
{
if config.db_conn_type == DbConnectionType::Sqlx {
match config.db_conn_type {
DbConnectionType::Sqlx => {
success(
t!("create_success_sqlx", project_name = project_name).replace(r"\n", "\n"),
);
}
if config.db_conn_type == DbConnectionType::SeaOrm {
DbConnectionType::SeaOrm => {
success(
t!("create_success_sea_orm", project_name = project_name)
.replace(r"\n", "\n"),
t!("create_success_sea_orm", project_name = project_name).replace(r"\n", "\n"),
);
}
if config.db_type == DbType::Sqlite {
success(t!("create_success_sqlx_sqlite").replace(r"\n", "\n"));
} else {
success(t!("create_success_mysql_or_pgsql").replace(r"\n", "\n"));
DbConnectionType::Diesel => {
match config.db_type {
DbType::Sqlite => {
success(t!("create_success_sqlx_sqlite").replace(r"\n", "\n"));
}
_ => {
success(t!("create_success_mysql_or_pgsql").replace(r"\n", "\n"));
}
}
}
}
if let (DbConnectionType::Rbatis, DbType::Mysql | DbType::Postgres | DbType::Mssql) =
(config.db_conn_type, config.db_type)
{
success(t!("create_success_rbatis"));
DbConnectionType::Rbatis => {
match config.db_type {
DbType::Mysql | DbType::Postgres | DbType::Mssql => {
success(t!("create_success_rbatis"));
}
_ => {}
}
}
_ => {}
}
}
None => anyhow::bail!("cli quit!"),
Expand Down

0 comments on commit ea89b95

Please sign in to comment.