Open billy1624 opened 1 year ago
Comments? @tyt2y3
Agree. I think there should be a default path where we load this file from, i.e. somewhere in the output_dir
.
This would encourage projects to actually commit this file into the repo, somewhat like ts.config.json
Second, only options related to entity generation can be specified, the following:
"max_connections": 1,
"output_dir": "out",
"database_schema": "public",
"database_url": "postgres://root:root@localhost/database",
should NOT be included.
I would like to work on this issue. I will like to use the https://github.com/mehcode/config-rs
lib. Which seem to support multiple types as multiple config file hierarchy.
Apparently config-rs is written by one of the SQLx authors
Nice fact
Acc. To you which approach is better
Let the config options be defined on per argument bases and let the function each handle there config files on there own. Advantages :-
Let the options be Changed before they are passed to there respective function and change the values which come from the clap::Cli enum. Advantages :-
I am not used to open source much. So if the thinks are say seem too basic or are wrong please do let me know. Also there seem to be a config feature discussion going on in the clap crate which can solve this problem entirely.
Sorry for the late reply, if you want to work on it, feel free and just do whatever you think makes the most sense!
I think we always want cli params to override the config file, so it's a two pass process, we first load a config file, and then override the options with the cli params. I think the serde struct can be shared with https://crates.io/crates/structopt thus removing code duplication.
@tyt2y3 If you have suggestion for improvement let me know.
Motivation
The options and flags for
sea-orm-cli generate entity
command is getting more and more. It's time to consider a scalable plan: loading the options from a config file.Proposed Solutions
Load all options by providing the path to the config file:
sea-orm-cli generate entity --config generate-entity.config.json
. The config file must be a JSON value.Related Discussion