Skip to content

Commit

Permalink
Happy weeeekend func
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbrgstrm committed Feb 3, 2023
1 parent 69baba6 commit 189ec6e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ color: "#46D9FF"
webhook_url: "<Teams webhook url>"
notifications: true
vab_msg: "Jag vabbar idag, försök hålla skutan flytande så är jag tillbaks imorgon"
weekend_msg: "Trevlig helg!"
time_sheet:
employee_id: "0000",
path: "/home/burton/.butlerburton/"
Expand Down
2 changes: 2 additions & 0 deletions cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Config struct {
Notifications bool `yaml:"notifications"`
VabMsg string `yaml:"vab_msg"`
TimeSheet TimeSheet `yaml:"time_sheet"`
WeekEndMsg string `yaml:"weekend_msg"`
}

type TimeSheet struct {
Expand Down Expand Up @@ -87,6 +88,7 @@ func createDefaultConfig(path string) {
WebhookURL: "",
Notifications: true,
VabMsg: "Jag vabbar idag, försök hålla skutan flytande så är jag tillbaka imorgon",
WeekEndMsg: "Trevlig helg!",
TimeSheet: TimeSheet{
EmployeeID: "0000",
Path: os.Getenv("HOME") + "/.butlerburton/",
Expand Down
12 changes: 12 additions & 0 deletions cmd/checkoutCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,15 @@ func calculateOvertime(tci time.Duration) string {

return ""
}

func WeekendCheckout(opts util.Options) error {
if opts.Loud {
util.SendTeamsMessage(
fmt.Sprintf("%s checkar ut", cfg.Cfg.Name),
cfg.Cfg.WeekEndMsg,
cfg.Cfg.Color,
cfg.Cfg.WebhookURL,
)
}
return nil
}
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func main() {
Catered: false,
Overtime: false,
Vab: false,
Weekend: false,
ShowStatus: false,
Loud: false,
}
Expand Down Expand Up @@ -96,8 +97,18 @@ func main() {
Usage: "write overtime to overtime column",
Destination: &opts.Overtime,
},
&cli.BoolFlag{
Name: "weekend",
Aliases: []string{"w"},
Value: false,
Usage: "check out with weekend message",
Destination: &opts.Weekend,
},
},
Action: func(c *cli.Context) error {
if opts.Weekend {
return cmd.WeekendCheckout(opts)
}
return cmd.Checkout(opts)
},
},
Expand Down
1 change: 1 addition & 0 deletions util/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ type Options struct {
Vab bool
ShowStatus bool
Loud bool
Weekend bool
}

0 comments on commit 189ec6e

Please sign in to comment.