8000 Add basic format option by sfrique · Pull Request #114 · dominikbraun/timetrace · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add basic format option #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cli/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cli

import (
"errors"
"fmt"
"strings"

"github.com/dominikbraun/timetrace/core"
"github.com/dominikbraun/timetrace/out"
Expand All @@ -10,6 +12 8CEA ,8 @@ import (
)

func statusCommand(t *core.Timetrace) *cobra.Command {
var format string

status := &cobra.Command{
Use: "status",
Short: "Display the current tracking status",
Expand Down Expand Up @@ -48,9 +52,21 @@ func statusCommand(t *core.Timetrace) *cobra.Command {
t.Formatter().FormatBreakTime(report),
},
}
if format != "" {
format = strings.ReplaceAll(format, "{project}", project)
format = strings.ReplaceAll(format, "{trackedTimeCurrent}", trackedTimeCurrent)
format = strings.ReplaceAll(format, "{todayTime}", t.Formatter().FormatTodayTime(report))
format = strings.ReplaceAll(format, "{breakTime}", t.Formatter().FormatBreakTime(report))
format = strings.ReplaceAll(format, `\n`, "\n")
fmt.Printf(format)
return
}

out.Table([]string{"Current project", "Worked since start", "Worked today", "Breaks"}, rows, nil)
},
}

status.Flags().StringVarP(&format, "format", "f", "", "Format string, availiable:\n{project}, {trackedTimeCurrent}, {todayTime}, {breakTime}")

return status
}
0