feat: better flags
All checks were successful
Go / build (push) Successful in 38s

This commit is contained in:
2025-11-04 21:15:05 +01:00
parent cfbb475a42
commit e5169ee0c4
11 changed files with 57 additions and 731 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"time"
"code.gitea.io/sdk/gitea"
"git.schreifuchs.ch/lou-taylor/accounting/internal/email"
"git.schreifuchs.ch/lou-taylor/accounting/pkg/invoice"
)
@@ -15,6 +16,7 @@ import (
type createFlags struct {
Email bool `flag:"email" help:"send invoice by email"`
Output string `flag:"o" help:"output file"`
Label string `flag:"l" help:"filters for issues with the label"`
}
func create(arguments []string, c any) {
@@ -33,6 +35,21 @@ func create(arguments []string, c any) {
}
opts := invoice.DefaultOptions
if flags.Label != "" {
opts.IssueState = gitea.StateAll
opts.IssueFilter = func(i *gitea.Issue) bool {
for _, l := range i.Labels {
if l.Name == flags.Label {
return true
}
}
return false
}
}
opts.Since = time.Now().AddDate(-1, 0, 0)
opts.Mindur = time.Duration(req.DurationThreshold)
invoice, report, err := invoicer.Generate(req.Creditor, req.Debtor, req.HourlyRate, repos, &opts)
if err != nil {