Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sea-orm-cli Implement derives & attributes parameters for entity generation #1124

Merged
18 changes: 18 additions & 0 deletions sea-orm-cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,24 @@ pub enum GenerateSubcommands {
help = "Generate index file as `lib.rs` instead of `mod.rs`."
)]
lib: bool,

#[clap(
value_parser,
long,
use_value_delimiter = true,
takes_value = true,
help = "Add extra derive macros to generated model structs (comma separated), ex. `ts_rs::Ts`"
)]
derives: Vec<String>,

#[clap(
value_parser,
long,
use_value_delimiter = true,
takes_value = true,
help = r#"Add extra attributes to generated model struct, no need for `#[]` (comma separated), ex. `-- attributes "serde(rename_all = \"camelCase\")","ts(export)"`"#
)]
attributes: Vec<String>,
},
}

Expand Down
4 changes: 4 additions & 0 deletions sea-orm-cli/src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub async fn run_generate_command(
with_copy_enums,
date_time_crate,
lib,
derives,
attributes,
} => {
if verbose {
let _ = tracing_subscriber::fmt()
Expand Down Expand Up @@ -169,6 +171,8 @@ pub async fn run_generate_command(
let writer_context = EntityWriterContext::new(
expanded_format,
WithSerde::from_str(&with_serde).unwrap(),
derives,
attributes,
with_copy_enums,
date_time_crate.into(),
schema_name,
Expand Down
Loading