summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-01-29 09:36:07 +0100
committerGitHub <noreply@github.com>2018-01-29 09:36:07 +0100
commit20f9c99c8304f2a09d03897f77a973445cbaea18 (patch)
tree7574cebd3f819f5956b33fd8cbdf0b9b9d5549d3
parent3735fbac2f68729bf5c855636179e6f3ea038f5d (diff)
parent53bf1a513b81cf85e132005219f6370f119bea84 (diff)
downloadimag-20f9c99c8304f2a09d03897f77a973445cbaea18.zip
imag-20f9c99c8304f2a09d03897f77a973445cbaea18.tar.gz
Merge pull request #1220 from matthiasbeyer/imag-timetrack/stop-all
imag-timetrack: Implement stopping all tags which are started
-rw-r--r--bin/domain/imag-timetrack/src/stop.rs31
-rw-r--r--bin/domain/imag-timetrack/src/ui.rs4
-rw-r--r--doc/src/09020-changelog.md1
3 files changed, 27 insertions, 9 deletions
diff --git a/bin/domain/imag-timetrack/src/stop.rs b/bin/domain/imag-timetrack/src/stop.rs
index 6497909..d0f17ea 100644
--- a/bin/domain/imag-timetrack/src/stop.rs
+++ b/bin/domain/imag-timetrack/src/stop.rs
@@ -23,6 +23,7 @@ use filters::filter::Filter;
use libimagerror::trace::trace_error;
use libimagerror::iter::TraceIterator;
+use libimagerror::trace::MapErrTrace;
use libimagrt::runtime::Runtime;
use libimagtimetrack::timetracking::TimeTracking;
@@ -48,14 +49,30 @@ pub fn stop(rt: &Runtime) -> i32 {
}
};
-
- // TODO: We do not yet support stopping all tags by simply calling the "stop" subcommand!
-
let tags : Vec<TimeTrackingTag> = cmd.values_of("tags")
- .unwrap() // enforced by clap
- .map(String::from)
- .map(TimeTrackingTag::from)
- .collect();
+ .map(|tags| tags.map(String::from).map(TimeTrackingTag::from).collect())
+ .unwrap_or_else(|| {
+ // Get all timetrackings which do not have an end datetime.
+ rt.store()
+ .get_timetrackings()
+ .map_err_trace_exit_unwrap(1)
+ .filter_map(|tracking| {
+ let tracking = tracking.map_err_trace_exit_unwrap(1);
+ let is_none = tracking
+ .get_end_datetime()
+ .map_err_trace_exit_unwrap(1)
+ .is_none();
+
+ if is_none {
+ Some(tracking)
+ } else {
+ None
+ }
+ })
+ .map(|t| t.get_timetrack_tag())
+ .map(|r| r.map_err_trace_exit_unwrap(1))
+ .collect()
+ });
let iter : GetTimeTrackIter = match rt.store().get_timetrackings() {
Ok(i) => i,
diff --git a/bin/domain/imag-timetrack/src/ui.rs b/bin/domain/imag-timetrack/src/ui.rs
index cefcef8..7f3c4d4 100644
--- a/bin/domain/imag-timetrack/src/ui.rs
+++ b/bin/domain/imag-timetrack/src/ui.rs
@@ -67,11 +67,11 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.version("0.1")
.arg(Arg::with_name("end-time")
.index(1)
- .required(true)
+ .required(false)
.help("End-time when to stop the timetracking (use 'now' for current time)"))
.arg(Arg::with_name("tags")
.index(2)
- .required(true)
+ .required(false)
.multiple(true)
.help("Tags to stop"))
)
diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md
index bbce7b8..4756bc8 100644
--- a/doc/src/09020-changelog.md
+++ b/doc/src/09020-changelog.md
@@ -38,6 +38,7 @@ This section contains the changelog from the last release to the next release.
* `libimagbookmark` does not longer wrap types from the store.
* The `toml-query` dependency was updated to 0.5.0
* `imag-timetrack list` lists with a table now
+ * `imag-timetrack stop` now stops all runnings tags if none are specified
* Bugfixes
## 0.5.0