refactor: seperate application into seperate files and add killForwarding
This commit is contained in:
parent
fec43ea77d
commit
a7ea6f41a7
7 changed files with 481 additions and 357 deletions
46
timewarrior.go
Normal file
46
timewarrior.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
type TimeWarrior struct{}
|
||||
|
||||
func NewTimeWarrior() *TimeWarrior {
|
||||
return &TimeWarrior{}
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) runCommand(args ...string) error {
|
||||
cmd := exec.Command("timew", args...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stdin = os.Stdin
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) StartWork() error {
|
||||
return t.runCommand("start", "work")
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) StopWork() error {
|
||||
return t.runCommand("stop", "work")
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) StartBreak() error {
|
||||
return t.runCommand("track", "break")
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) StopBreak() error {
|
||||
return t.runCommand("track", "work")
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) ShowSummary(period string) error {
|
||||
return t.runCommand("summary", period, "work")
|
||||
}
|
||||
|
||||
func (t *TimeWarrior) ExportSummary() error {
|
||||
fmt.Println("Export Timetable")
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue