Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Jan 17, 2025
1 parent 2da6ca1 commit 0db7a23
Showing 1 changed file with 34 additions and 40 deletions.
74 changes: 34 additions & 40 deletions src/templates/classic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,62 +68,56 @@ fn create_files(project_path: &Path, user_selected: Selected, new_cmd: &NewCmd)
"create_success_seaorm__mysql_or_pgsql_fist_use":t!("create_success_seaorm__mysql_or_pgsql_fist_use").replace(r"\n", "\n"),
"create_success_diesel__mysql_or_pgsql_fist_use":t!("create_success_diesel__mysql_or_pgsql_fist_use").replace(r"\n", "\n"),

"is_starting": t!("is_starting"),
"listen_on": t!("listen_on"),
"database_connection_failed": t!("database_connection_failed"),
"user_does_not_exist": t!("user_does_not_exist"),
"rust_version_tip": t!("rust_version_tip"),
"introduction_title": t!("introduction_title"),
"introduction_content": t!("introduction_content"),
"seleted_sqlite": t!("seleted_sqlite"),
"run_the_project": t!("run_the_project"),
"run_the_tests": t!("run_the_tests"),
"sqlx_cli": t!("sqlx_cli"),
"about_salvo": t!("about_salvo"),
"about_salvo_text": t!("about_salvo_text"),
"tip_title": t!("tip_title"),
"password_tip": t!("password_tip"),
"config_tip": t!("config_tip"),
"orm_title": t!("orm_title"),
"sqlx_website": t!("sqlx_website"),
"seaorm_website": t!("seaorm_website"),
"diesel_website": t!("diesel_website"),
"rbatis_website": t!("rbatis_website"),
"mongodb_website": t!("mongodb_website"),
"initialization": t!("initialization"),
"initialization_sqlx_cli_not_sqlite":
t!("initialization_sqlx_cli_not_sqlite").replace(r"\n", "\n"),
"initialization_seaorm_cli_not_sqlite":
t!("initialization_seaorm_cli_not_sqlite").replace(r"\n", "\n"),
"initialization_diesel_cli_not_sqlite":
t!("initialization_diesel_cli_not_sqlite").replace(r"\n", "\n"),
"initialization_rbatis_cli_not_sqlite":
t!("initialization_rbatis_cli_not_sqlite").replace(r"\n", "\n"),
"seaorm_cli_website": t!("seaorm_cli_website").replace(r"\n", "\n"),
"diesel_cli_website": t!("diesel_cli_website").replace(r"\n", "\n"),
"mongodb_usage_import_user_data":
t!("mongodb_usage_import_user_data").replace(r"\n", "\n")
"is_starting": t!("is_starting"),
"listen_on": t!("listen_on"),
"database_connection_failed": t!("database_connection_failed"),
"user_does_not_exist": t!("user_does_not_exist"),
"rust_version_tip": t!("rust_version_tip"),
"introduction_title": t!("introduction_title"),
"introduction_content": t!("introduction_content"),
"seleted_sqlite": t!("seleted_sqlite"),
"run_the_project": t!("run_the_project"),
"run_the_tests": t!("run_the_tests"),
"sqlx_cli": t!("sqlx_cli"),
"about_salvo": t!("about_salvo"),
"about_salvo_text": t!("about_salvo_text"),
"tip_title": t!("tip_title"),
"password_tip": t!("password_tip"),
"config_tip": t!("config_tip"),
"orm_title": t!("orm_title"),
"sqlx_website": t!("sqlx_website"),
"seaorm_website": t!("seaorm_website"),
"diesel_website": t!("diesel_website"),
"rbatis_website": t!("rbatis_website"),
"mongodb_website": t!("mongodb_website"),
"initialization": t!("initialization"),
"initialization_sqlx_cli_not_sqlite": t!("initialization_sqlx_cli_not_sqlite").replace(r"\n", "\n"),
"initialization_seaorm_cli_not_sqlite": t!("initialization_seaorm_cli_not_sqlite").replace(r"\n", "\n"),
"initialization_diesel_cli_not_sqlite": t!("initialization_diesel_cli_not_sqlite").replace(r"\n", "\n"),
"initialization_rbatis_cli_not_sqlite": t!("initialization_rbatis_cli_not_sqlite").replace(r"\n", "\n"),
"seaorm_cli_website": t!("seaorm_cli_website").replace(r"\n", "\n"),
"diesel_cli_website": t!("diesel_cli_website").replace(r"\n", "\n"),
"mongodb_usage_import_user_data": t!("mongodb_usage_import_user_data").replace(r"\n", "\n")
});

let db_lib_str = &*user_selected.db_lib.to_string();
for filename in Template::iter() {
if filename.starts_with("_base/") {
let file = Template::get(filename.as_ref()).expect("file must exist");
let file_path = project_path.join(filename.as_ref().trim_start_matches("_base/"));
write_file(&file.data, &file_path, &data)?;
} else if filename.starts_with("_data/") {
if filename.contains(user_selected.db_lib.to_string().as_str())
&& filename.contains(user_selected.db_type.to_string().as_str())
{
if filename.contains(db_lib_str) && filename.contains(db_lib_str) {
let file = Template::get(filename.as_ref()).expect("file must exist");
let file_path = project_path.join(filename.as_ref().trim_start_matches("_"));
write_file(&file.data, &file_path, &data)?;
}
} else if filename.starts_with(user_selected.db_lib.to_string().as_str()) {
} else if filename.starts_with(&format!("{}/", db_lib_str)) {
let file = Template::get(filename.as_ref()).expect("file must exist");
let file_path = project_path.join(
filename
.as_ref()
.trim_start_matches(user_selected.db_lib.to_string().as_str()),
.trim_start_matches(&format!("{}/", db_lib_str)),
);
write_file(&file.data, &file_path, &data)?;
}
Expand Down

0 comments on commit 0db7a23

Please sign in to comment.