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 ea89b95 commit 45fa18b
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,46 @@ pub fn create_project(project: Project) -> Result<()> {

init_git(project_path)?;

success(t!("create_success", project_name = project_name).replace(r"\n", "\n"));
match config.db_conn_type {
DbConnectionType::Sqlx => {
success(
t!("create_success_sqlx", project_name = project_name).replace(r"\n", "\n"),
);
}
DbConnectionType::SeaOrm => {
success(
t!("create_success_sea_orm", project_name = project_name).replace(r"\n", "\n"),
);
after_print_info(project_name, config);
}
None => anyhow::bail!("cli quit!"),
}
Ok(())
}

fn after_print_info(project_name: &String, config: UserSelected) {
success(t!("create_success", project_name = project_name).replace(r"\n", "\n"));
match config.db_conn_type {
DbConnectionType::Sqlx => {
success(
t!("create_success_sqlx", project_name = project_name).replace(r"\n", "\n"),
);
}
DbConnectionType::SeaOrm => {
success(
t!("create_success_sea_orm", project_name = project_name).replace(r"\n", "\n"),
);
}
DbConnectionType::Diesel => {
match config.db_type {
DbType::Sqlite => {
success(t!("create_success_sqlx_sqlite").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"));
}
}
_ => {
success(t!("create_success_mysql_or_pgsql").replace(r"\n", "\n"));
}
DbConnectionType::Rbatis => {
match config.db_type {
DbType::Mysql | DbType::Postgres | DbType::Mssql => {
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!"),
_ => {}
}
Ok(())
}

fn write_project_file(
Expand Down

0 comments on commit 45fa18b

Please sign in to comment.