Merge pull request #1317 from matthiasbeyer/imag-diary/daily

imag diary: "daily" support + Fixes for other timed entries
This commit is contained in:
Matthias Beyer 2018-03-03 13:29:10 +01:00 committed by GitHub
commit 590a2e8f1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 2 deletions

View file

@ -106,9 +106,18 @@ fn create_id_from_clispec(create: &ArgMatches, diaryname: &str, timed_type: Time
};
match timed_type {
Timed::Daily => {
debug!("Creating daily-timed entry");
get_hourly_id(create)
.with_hour(0)
.with_minute(0)
.with_second(0)
},
Timed::Hourly => {
debug!("Creating hourly-timed entry");
get_hourly_id(create)
.with_minute(0)
.with_second(0)
},
Timed::Minutely => {
@ -124,6 +133,7 @@ fn create_id_from_clispec(create: &ArgMatches, diaryname: &str, timed_type: Time
.unwrap_or(time.minute());
time.with_minute(min)
.with_second(0)
},
Timed::Secondly => {

View file

@ -33,6 +33,7 @@ pub fn get_diary_name(rt: &Runtime) -> Option<String> {
}
pub enum Timed {
Daily,
Hourly,
Minutely,
Secondly,
@ -63,7 +64,7 @@ pub fn get_diary_timed_config(rt: &Runtime, diary_name: &str) -> Result<Option<T
Ok(Some(&Value::String(ref s))) => parse_timed_string(s, diary_name).map(Some),
Ok(Some(_)) => {
let s = format!("Type error at 'diary.diaryies.{}.timed': should be either 'h'/'hourly' or 'm'/'minutely'", diary_name);
let s = format!("Type error at 'diary.diaryies.{}.timed': should be either 'd'/'daily', 'h'/'hourly', 'm'/'minutely' or 's'/'secondly'", diary_name);
Err(s).map_err(From::from)
},
@ -75,7 +76,9 @@ pub fn get_diary_timed_config(rt: &Runtime, diary_name: &str) -> Result<Option<T
}
pub fn parse_timed_string(s: &str, diary_name: &str) -> Result<Timed> {
if s == "h" || s == "hourly" {
if s == "d" || s == "daily" {
Ok(Timed::Daily)
} else if s == "h" || s == "hourly" {
Ok(Timed::Hourly)
} else if s == "m" || s == "minutely" {
Ok(Timed::Minutely)

View file

@ -46,6 +46,7 @@ This section contains the changelog from the last release to the next release.
* `imag-log show` was aliased to `imag-log list`
* `imag-* --version` shows `git describe` output if binary was compiled in
"debug" mode.
* `imag-diary` supports "daily" diaries now.
* Bugfixes
* imag does not panic anymore when piping and breaking that pipe, for
example like with `imag store ids | head -n 1`.
@ -62,6 +63,7 @@ This section contains the changelog from the last release to the next release.
with a line "---" in the content part to fail, was fixed.
* The patch explained by the point above introduced a bug which caused
entries to be read as a single line, which was fixed as well.
* `imag-diary create --timed` did not work as expected
## 0.6.1