specify in readme how to use a development database
This commit is contained in:
parent
73a0b62c75
commit
1365d6d466
|
@ -1,4 +1,5 @@
|
|||
/target
|
||||
fake_old_config.yml
|
||||
/*.yml
|
||||
.env
|
||||
tiempo.sqlite3
|
||||
/*.sqlite3
|
||||
dev_config.toml
|
||||
|
|
13
README.md
13
README.md
|
@ -194,6 +194,19 @@ Run
|
|||
|
||||
to see the options.
|
||||
|
||||
### Development database
|
||||
|
||||
When developing I prefer not to mess with my own database, so I use this `.env`
|
||||
file:
|
||||
|
||||
export TIMETRAP_CONFIG_FILE=/absolute/path/to/repo/dev_config.toml
|
||||
PS1="$ "
|
||||
|
||||
and when I want to test some commands against such config file I just source it:
|
||||
|
||||
source .env
|
||||
cargo run -- in 'hola'
|
||||
|
||||
## Special Thanks
|
||||
|
||||
To [timetrap](https://github.com/samg/timetrap) for existing. It is the tool I
|
||||
|
|
|
@ -68,11 +68,17 @@ impl Config {
|
|||
pub fn read() -> Result<Config> {
|
||||
// first try from env variable TIMETRAP_CONFIG_FILE
|
||||
if let Ok(value) = env::var("TIMETRAP_CONFIG_FILE") {
|
||||
if value.ends_with(".toml") {
|
||||
return Self::read_from_toml(value);
|
||||
return if value.ends_with(".toml") {
|
||||
let config_path = PathBuf::from(&value);
|
||||
|
||||
if config_path.is_file() {
|
||||
Self::read_from_toml(value)
|
||||
} else {
|
||||
Self::create_and_return_config(config_path.parent().unwrap(), &config_path)
|
||||
}
|
||||
} else {
|
||||
return Self::read_from_yaml(value);
|
||||
}
|
||||
Self::read_from_yaml(value)
|
||||
};
|
||||
}
|
||||
|
||||
// Next try from some known directories
|
||||
|
|
Loading…
Reference in New Issue