Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislearn committed Jan 16, 2025
1 parent 908a940 commit 3a9121f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn create_files(project_path: &Path, user_selected: UserSelected, data: &Object)
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())
&& filename.contains(user_selected.db_type.to_string().as_str())
{
let file = Template::get(filename.as_ref()).expect("file must exist");
let file_path = project_path.join(filename.as_ref().trim_start_matches("_"));
Expand Down
20 changes: 15 additions & 5 deletions src/utils/get_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,21 @@ pub fn get_user_selected() -> Result<Option<UserSelected>> {
1 => DbLib::SeaOrm,
2 => DbLib::Diesel,
3 => DbLib::Rbatis,
4 => DbLib::Mongodb,
_ => anyhow::bail!("Invalid db connection type selection"),
};
let mut db_types: Vec<&str> = vec!["sqlite", "mysql", "postgres"];
if db_lib == DbLib::Rbatis {
db_types = vec!["sqlite", "mysql", "postgres", "mssql"];
if db_lib == DbLib::Mongodb {
return Ok(Some(UserSelected {
code_gen,
db_type: DbType::Mongodb,
db_lib,
}));
}

let mut db_types: Vec<&str> = vec!["sqlite", "mysql", "postgres"];
// if db_lib == DbLib::Rbatis {
// db_types = vec!["sqlite", "mysql", "postgres", "mssql"];
// }
let db_type_selection = Select::with_theme(&theme)
.with_prompt(t!("select_db_type").replace(r"\n", "\n"))
.default(0)
Expand All @@ -64,7 +73,6 @@ pub fn get_user_selected() -> Result<Option<UserSelected>> {
0 => DbType::Sqlite,
1 => DbType::Mysql,
2 => DbType::Postgres,
3 => DbType::Mongodb,
_ => anyhow::bail!("Invalid db type selection"),
};

Expand Down Expand Up @@ -96,7 +104,9 @@ pub enum DbLib {
#[strum(serialize = "diesel")]
Diesel,
#[strum(serialize = "rbatis")]
Rbatis
Rbatis,
#[strum(serialize = "mongodb")]
Mongodb
}

#[derive(Debug, PartialEq, Clone, Copy, strum::Display)]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 3a9121f

Please sign in to comment.