Skip to content

Commit

Permalink
Add ignore_tables and hidden_tables CLI arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
karatakis authored Oct 21, 2022
1 parent d5c5196 commit d50cea4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ pub struct Args {

#[clap(short, long)]
pub complexity_limit: Option<usize>,

#[clap(short, long)]
pub ignore_tables: Option<String>,

#[clap(short, long)]
pub hidden_tables: Option<bool>,
}

/**
Expand Down Expand Up @@ -97,6 +103,34 @@ async fn main() {

let expanded_format = args.expanded_format.unwrap_or(false);

let ignore_tables = args
.ignore_tables
.unwrap_or_else(|| "seaql_migrations".into());
let ignore_tables: Vec<&str> = ignore_tables.split(",").collect();

let hidden_tables = args.hidden_tables.unwrap_or(true);

let tables: std::collections::BTreeMap<
String,
seaography_discoverer::sea_schema::sea_query::TableCreateStatement,
> = tables
.into_iter()
.filter(|(key, _)| {
if hidden_tables {
!key.starts_with("_")
} else {
true
}
})
.filter(|(key, _)| {
if !ignore_tables.is_empty() {
!ignore_tables.contains(&key.as_str())
} else {
true
}
})
.collect();

let db_url = database_url.as_str();

write_project(
Expand Down

0 comments on commit d50cea4

Please sign in to comment.