summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-03-03 13:29:10 +0100
committerGitHub <noreply@github.com>2018-03-03 13:29:10 +0100
commit590a2e8f1d6d16fec22073c1b38312352da8c3bb (patch)
tree1104a5d2a38da45f1cbb642e4e1884028b115294
parentc9af23f6634031969e1e53bf293ef99895531c99 (diff)
parent39a00dc65a654d9742b7ab6285ec4380255cbc70 (diff)
downloadimag-590a2e8f1d6d16fec22073c1b38312352da8c3bb.zip
imag-590a2e8f1d6d16fec22073c1b38312352da8c3bb.tar.gz
Merge pull request #1317 from matthiasbeyer/imag-diary/daily
imag diary: "daily" support + Fixes for other timed entries
-rw-r--r--bin/domain/imag-diary/src/create.rs10
-rw-r--r--bin/domain/imag-diary/src/util.rs7
-rw-r--r--doc/src/09020-changelog.md2
3 files changed, 17 insertions, 2 deletions
diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs
index e86ada0..148c4b5 100644
--- a/bin/domain/imag-diary/src/create.rs
+++ b/bin/domain/imag-diary/src/create.rs
@@ -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 => {
diff --git a/bin/domain/imag-diary/src/util.rs b/bin/domain/imag-diary/src/util.rs
index aeff186..db56b7c 100644
--- a/bin/domain/imag-diary/src/util.rs
+++ b/bin/domain/imag-diary/src/util.rs
@@ -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)
diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md
index 76b2f83..a0a6384 100644
--- a/doc/src/09020-changelog.md
+++ b/doc/src/09020-changelog.md
@@ -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