Archived
1
0
Fork 0

feat(cli): add database config

This commit is contained in:
Dmitriy Pleshevskiy 2021-01-31 13:40:02 +03:00
parent d8ed9fd25a
commit a14d67105e

View file

@ -6,17 +6,27 @@ const MIGRA_TOML_FILENAME: &str = "Migra.toml";
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub(crate) struct Config { pub(crate) struct Config {
directory: String, pub directory: String,
pub database: DatabaseConfig,
}
#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct DatabaseConfig {
pub connection: String
} }
impl Default for Config { impl Default for Config {
fn default() -> Config { fn default() -> Config {
Config { Config {
directory: String::from("database"), directory: String::from("database"),
database: DatabaseConfig {
connection: String::new(),
}
} }
} }
} }
impl Config { impl Config {
pub fn read() -> Config { pub fn read() -> Config {
fs::read_to_string(MIGRA_TOML_FILENAME) fs::read_to_string(MIGRA_TOML_FILENAME)