Merge pull request #1317 from matthiasbeyer/imag-diary/daily
imag diary: "daily" support + Fixes for other timed entries
This commit is contained in:
commit
590a2e8f1d
3 changed files with 17 additions and 2 deletions
|
@ -106,9 +106,18 @@ fn create_id_from_clispec(create: &ArgMatches, diaryname: &str, timed_type: Time
|
||||||
};
|
};
|
||||||
|
|
||||||
match timed_type {
|
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 => {
|
Timed::Hourly => {
|
||||||
debug!("Creating hourly-timed entry");
|
debug!("Creating hourly-timed entry");
|
||||||
get_hourly_id(create)
|
get_hourly_id(create)
|
||||||
|
.with_minute(0)
|
||||||
|
.with_second(0)
|
||||||
},
|
},
|
||||||
|
|
||||||
Timed::Minutely => {
|
Timed::Minutely => {
|
||||||
|
@ -124,6 +133,7 @@ fn create_id_from_clispec(create: &ArgMatches, diaryname: &str, timed_type: Time
|
||||||
.unwrap_or(time.minute());
|
.unwrap_or(time.minute());
|
||||||
|
|
||||||
time.with_minute(min)
|
time.with_minute(min)
|
||||||
|
.with_second(0)
|
||||||
},
|
},
|
||||||
|
|
||||||
Timed::Secondly => {
|
Timed::Secondly => {
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub fn get_diary_name(rt: &Runtime) -> Option<String> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Timed {
|
pub enum Timed {
|
||||||
|
Daily,
|
||||||
Hourly,
|
Hourly,
|
||||||
Minutely,
|
Minutely,
|
||||||
Secondly,
|
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(&Value::String(ref s))) => parse_timed_string(s, diary_name).map(Some),
|
||||||
|
|
||||||
Ok(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)
|
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> {
|
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)
|
Ok(Timed::Hourly)
|
||||||
} else if s == "m" || s == "minutely" {
|
} else if s == "m" || s == "minutely" {
|
||||||
Ok(Timed::Minutely)
|
Ok(Timed::Minutely)
|
||||||
|
|
|
@ -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-log show` was aliased to `imag-log list`
|
||||||
* `imag-* --version` shows `git describe` output if binary was compiled in
|
* `imag-* --version` shows `git describe` output if binary was compiled in
|
||||||
"debug" mode.
|
"debug" mode.
|
||||||
|
* `imag-diary` supports "daily" diaries now.
|
||||||
* Bugfixes
|
* Bugfixes
|
||||||
* imag does not panic anymore when piping and breaking that pipe, for
|
* imag does not panic anymore when piping and breaking that pipe, for
|
||||||
example like with `imag store ids | head -n 1`.
|
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.
|
with a line "---" in the content part to fail, was fixed.
|
||||||
* The patch explained by the point above introduced a bug which caused
|
* 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.
|
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
|
## 0.6.1
|
||||||
|
|
Loading…
Reference in a new issue