Merge pull request #1220 from matthiasbeyer/imag-timetrack/stop-all
imag-timetrack: Implement stopping all tags which are started
This commit is contained in:
commit
20f9c99c83
3 changed files with 27 additions and 9 deletions
|
@ -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,
|
||||
|
|
|
@ -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"))
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue