summaryrefslogtreecommitdiffstats
path: root/bin/domain/imag-timetrack/src/ui.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-07-25 20:23:51 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-07-25 20:32:33 +0200
commit6ac6db57d11eeb2393fe0771db630899e9ea326c (patch)
tree274329e4e3d37955ff22c1f1801685945c9e8074 /bin/domain/imag-timetrack/src/ui.rs
parentd5fd773da813832f93ee8bec59427b7b248d7373 (diff)
Add imag-timetrack shell
This patch adds a subcommand to imag-timetrack which allows a user to start a $SHELL and start a timetracking with it and as soon as the shell exits, the timetracking is stopped. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'bin/domain/imag-timetrack/src/ui.rs')
-rw-r--r--bin/domain/imag-timetrack/src/ui.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/bin/domain/imag-timetrack/src/ui.rs b/bin/domain/imag-timetrack/src/ui.rs
index a654a819..2803ec9b 100644
--- a/bin/domain/imag-timetrack/src/ui.rs
+++ b/bin/domain/imag-timetrack/src/ui.rs
@@ -183,4 +183,31 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.help("Limit to certain tags"))
)
+ .subcommand(SubCommand::with_name("shell")
+ .about("Start a shell and start timetracking, stop when shell exits")
+ .version("0.1")
+ .long_about(r#"
+ Tries to find the current shell via $SHELL. If none is found, this aborts operation and returns 1.
+ If a shell is found in the environment variables, the time tracking is created and the shell started.
+ As soon as the shell exits (no matter what exit code), the timetracking is stopped.
+ The command exits with the exit code of the shell it started. If there is no exit code, this exits with 0.
+ If there was a failure during setting the end-time, the command exits with the exit code of the shell anyways, but prints error information.
+ If the command for the shell could not be executed, this fails with 2.
+ "#)
+
+ .arg(Arg::with_name("shell")
+ .long("shell")
+ .short("s")
+ .required(false)
+ .multiple(false)
+ .takes_value(true)
+ .help("Shell to start, defaults to $SHELL"))
+
+ .arg(Arg::with_name("tags")
+ .index(1)
+ .required(true)
+ .multiple(true)
+ .help("Tags to start"))
+ )
+
}