Compare commits
6 Commits
163e7abf47
...
0.0.6
| Author | SHA1 | Date | |
|---|---|---|---|
| c7798c5784 | |||
| 6116e89aac | |||
| e1df2dea3b | |||
| 9a318d3cff | |||
| c6d8fee715 | |||
| 34a94fa269 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
# Added by goreleaser init:
|
|
||||||
dist/
|
dist/
|
||||||
|
.DS_Store
|
||||||
|
|||||||
224
mite/mite.go
224
mite/mite.go
@@ -3,6 +3,7 @@ package mite
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
@@ -50,13 +51,15 @@ type Project struct {
|
|||||||
func (p Project) String() string {
|
func (p Project) String() string {
|
||||||
return fmt.Sprintf("%d: %s (%s)", p.ID, p.Name, p.CustomerName)
|
return fmt.Sprintf("%d: %s (%s)", p.ID, p.Name, p.CustomerName)
|
||||||
}
|
}
|
||||||
func (p Project) GetID() int { return p.ID }
|
func (p Project) GetID() int { return p.ID }
|
||||||
func (p Project) GetName() string { return p.Name + " (" + p.CustomerName + ")" }
|
func (p Project) GetName() string {
|
||||||
|
return p.Name + " (" + p.CustomerName + ")"
|
||||||
|
}
|
||||||
|
|
||||||
func (a APIClient) GetProjects() (Projects, error) {
|
func (a APIClient) GetProjects() (Projects, error) {
|
||||||
// GET /projects.json
|
// GET /projects.json
|
||||||
p := APIProjects{}
|
p := APIProjects{}
|
||||||
err := get(a.domain, a.apiKey, "/projects.json", &p)
|
err := a.get("/projects.json", &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -98,7 +101,7 @@ func (c Customer) GetName() string { return c.Name }
|
|||||||
func (a APIClient) GetCustomers() (Customers, error) {
|
func (a APIClient) GetCustomers() (Customers, error) {
|
||||||
// GET /customers.json
|
// GET /customers.json
|
||||||
p := apiCustomers{}
|
p := apiCustomers{}
|
||||||
err := get(a.domain, a.apiKey, "/customers.json", &p)
|
err := a.get("/customers.json", &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -142,7 +145,7 @@ func (s Service) GetName() string {
|
|||||||
func (a APIClient) GetServices() (Services, error) {
|
func (a APIClient) GetServices() (Services, error) {
|
||||||
// GET /services.json
|
// GET /services.json
|
||||||
p := apiServices{}
|
p := apiServices{}
|
||||||
err := get(a.domain, a.apiKey, "/services.json", &p)
|
err := a.get("/services.json", &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -215,7 +218,7 @@ func (a APIClient) GetTimeEntries(from, to time.Time) (TimeEntries, error) {
|
|||||||
p := apiTimeEntry{}
|
p := apiTimeEntry{}
|
||||||
u := fmt.Sprintf("/time_entries.json?from=%s&to=%s", from.Format(time.DateOnly), to.Format(time.DateOnly))
|
u := fmt.Sprintf("/time_entries.json?from=%s&to=%s", from.Format(time.DateOnly), to.Format(time.DateOnly))
|
||||||
|
|
||||||
err := get(a.domain, a.apiKey, u, &p)
|
err := a.get(u, &p)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -237,7 +240,9 @@ type requestAddTimeEntry struct {
|
|||||||
} `json:"time_entry"`
|
} `json:"time_entry"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a APIClient) AddTimeEntry(date string, minutes int, notes string, projectId, serviceId int) error {
|
type apiPostTimeEntry timeEntryHolder
|
||||||
|
|
||||||
|
func (a APIClient) AddTimeEntry(date string, minutes int, notes string, projectId, serviceId int) (int, error) {
|
||||||
// POST /time_entries.json
|
// POST /time_entries.json
|
||||||
// {
|
// {
|
||||||
// "time_entry": {
|
// "time_entry": {
|
||||||
@@ -253,44 +258,113 @@ func (a APIClient) AddTimeEntry(date string, minutes int, notes string, projectI
|
|||||||
req.RequestTimeEntryHolder.ProjectID = projectId
|
req.RequestTimeEntryHolder.ProjectID = projectId
|
||||||
req.RequestTimeEntryHolder.ServiceID = serviceId
|
req.RequestTimeEntryHolder.ServiceID = serviceId
|
||||||
|
|
||||||
err := post(a.domain, a.apiKey, "/time_entries.json", req)
|
res := apiPostTimeEntry{}
|
||||||
return err
|
|
||||||
|
|
||||||
|
err := a.post("/time_entries.json", req, &res)
|
||||||
|
return res.TimeEntry.ID, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func post(domain, apiKey, path string, data any) error {
|
type apiTimeTrackerEntry struct {
|
||||||
|
TimeTrackerHolder timeTrackerHolder `json:"tracker"`
|
||||||
b, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", baseurl(domain, path), bytes.NewBuffer(b))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
req.Header.Add("X-MiteApiKey", apiKey)
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
|
||||||
resp, err := http.DefaultClient.Do(req)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
if resp.StatusCode >= 300 {
|
|
||||||
return fmt.Errorf("expected 2XX, got %d", resp.StatusCode)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func get(domain, apiKey, path string, data any) error {
|
type timeTrackerHolder struct {
|
||||||
req, err := http.NewRequest("GET", baseurl(domain, path), nil)
|
TrackingTimeEntry *TrackingTimeEntry `json:"tracking_time_entry"`
|
||||||
|
StoppedTimeEntry *StoppedTimeEntry `json:"stopped_time_entry"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TrackingTimeEntry struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Minutes int `json:"minutes"`
|
||||||
|
Since time.Time `json:"since"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type StoppedTimeEntry struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Minutes int `json:"minutes"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// {
|
||||||
|
// "tracker": {
|
||||||
|
// "tracking_time_entry": {
|
||||||
|
// "id": 36135322,
|
||||||
|
// "minutes": 0,
|
||||||
|
// "since": "2015-10-15T17:33:52+02:00"
|
||||||
|
// },
|
||||||
|
// "stopped_time_entry": {
|
||||||
|
// "id": 36134329,
|
||||||
|
// "minutes": 46
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// {
|
||||||
|
// "tracker": {
|
||||||
|
// "tracking_time_entry": {
|
||||||
|
// "id": 36135321,
|
||||||
|
// "minutes": 247,
|
||||||
|
// "since": "2015-10-15T17:05:04+02:00"
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
var ErrNoTracker = errors.New("no time tracker running")
|
||||||
|
|
||||||
|
// GetTimeTracker gets the current running time tracker. If no tracker is
|
||||||
|
// running, the error returned will be ErrNoTracker
|
||||||
|
func (a APIClient) GetTimeTracker() (TrackingTimeEntry, error) {
|
||||||
|
r := apiTimeTrackerEntry{}
|
||||||
|
err := a.get("/tracker.json", &r)
|
||||||
|
if err != nil {
|
||||||
|
return TrackingTimeEntry{}, err
|
||||||
|
}
|
||||||
|
if r.TimeTrackerHolder.TrackingTimeEntry == nil {
|
||||||
|
return TrackingTimeEntry{}, ErrNoTracker
|
||||||
|
}
|
||||||
|
return *r.TimeTrackerHolder.TrackingTimeEntry, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a APIClient) StartTimeTracker(id int) (TrackingTimeEntry, *StoppedTimeEntry, error) {
|
||||||
|
url := fmt.Sprintf("/tracker/%d.json", id)
|
||||||
|
r := apiTimeTrackerEntry{}
|
||||||
|
|
||||||
|
err := a.patch(url, &r)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return TrackingTimeEntry{}, nil, err
|
||||||
|
}
|
||||||
|
if r.TimeTrackerHolder.TrackingTimeEntry == nil {
|
||||||
|
// I don't think this should happen, the patch should have been a 404?
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unexpected failure to find a tracking entry in a successful PATCH\n%#v", r.TimeTrackerHolder))
|
||||||
|
}
|
||||||
|
return *r.TimeTrackerHolder.TrackingTimeEntry, r.TimeTrackerHolder.StoppedTimeEntry, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a APIClient) StopTimeTracker(id int) (StoppedTimeEntry, error) {
|
||||||
|
url := fmt.Sprintf("/tracker/%d.json", id)
|
||||||
|
r := apiTimeTrackerEntry{}
|
||||||
|
|
||||||
|
err := a.delete(url, &r)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return StoppedTimeEntry{}, err
|
||||||
|
}
|
||||||
|
if r.TimeTrackerHolder.StoppedTimeEntry == nil {
|
||||||
|
// I don't think this should happen, the patch should have been a 404?
|
||||||
|
|
||||||
|
panic(fmt.Sprintf("unexpected failure to find a tracking entry in a successful DELETE\n%#v", r.TimeTrackerHolder))
|
||||||
|
}
|
||||||
|
return *r.TimeTrackerHolder.StoppedTimeEntry, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a APIClient) delete(path string, data any) error {
|
||||||
|
|
||||||
|
req, err := http.NewRequest("DELETE", baseurl(a.domain, path), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
req.Header.Add("X-MiteApiKey", apiKey)
|
req.Header.Add("X-MiteApiKey", a.apiKey)
|
||||||
resp, err := http.DefaultClient.Do(req)
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -305,7 +379,83 @@ func get(domain, apiKey, path string, data any) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a APIClient) patch(path string, data any) error {
|
||||||
|
|
||||||
|
req, err := http.NewRequest("PATCH", baseurl(a.domain, path), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Header.Add("X-MiteApiKey", a.apiKey)
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode >= 300 {
|
||||||
|
return fmt.Errorf("expected 2XX, got %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a APIClient) post(path string, dataIn any, dataOut any) error {
|
||||||
|
|
||||||
|
b, err := json.Marshal(dataIn)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest("POST", baseurl(a.domain, path), bytes.NewBuffer(b))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Header.Add("X-MiteApiKey", a.apiKey)
|
||||||
|
req.Header.Add("Content-Type", "application/json")
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode >= 300 {
|
||||||
|
return fmt.Errorf("expected 2XX, got %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(&dataOut)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a APIClient) get(path string, data any) error {
|
||||||
|
req, err := http.NewRequest("GET", baseurl(a.domain, path), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Header.Add("X-MiteApiKey", a.apiKey)
|
||||||
|
resp, err := http.DefaultClient.Do(req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
if resp.StatusCode >= 300 {
|
||||||
|
return fmt.Errorf("expected 2XX, got %d", resp.StatusCode)
|
||||||
|
}
|
||||||
|
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func baseurl(domain, path string) string {
|
func baseurl(domain, path string) string {
|
||||||
|
|||||||
82
mite/mite_test.go
Normal file
82
mite/mite_test.go
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package mite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestUnmarshalTimeTracking(t *testing.T) {
|
||||||
|
|
||||||
|
trackerOff := []byte(`{
|
||||||
|
"tracker": {}
|
||||||
|
}`)
|
||||||
|
off := apiTimeTrackerEntry{}
|
||||||
|
err := json.Unmarshal(trackerOff, &off)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else {
|
||||||
|
if off.TimeTrackerHolder.TrackingTimeEntry != nil {
|
||||||
|
t.Error("expected nil, but is not")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trackerOn := []byte(`
|
||||||
|
{
|
||||||
|
"tracker": {
|
||||||
|
"tracking_time_entry": {
|
||||||
|
"id": 36135321,
|
||||||
|
"minutes": 247,
|
||||||
|
"since": "2015-10-15T17:05:04+02:00"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`)
|
||||||
|
on := apiTimeTrackerEntry{}
|
||||||
|
err = json.Unmarshal(trackerOn, &on)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else {
|
||||||
|
if on.TimeTrackerHolder.TrackingTimeEntry == nil {
|
||||||
|
t.Error("expected not nil, but is not")
|
||||||
|
} else {
|
||||||
|
if on.TimeTrackerHolder.TrackingTimeEntry.ID != 36135321 {
|
||||||
|
t.Error("bad unmarshal?")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
trackerStart := []byte(`{
|
||||||
|
"tracker": {
|
||||||
|
"tracking_time_entry": {
|
||||||
|
"id": 36135322,
|
||||||
|
"minutes": 0,
|
||||||
|
"since": "2015-10-15T17:33:52+02:00"
|
||||||
|
},
|
||||||
|
"stopped_time_entry": {
|
||||||
|
"id": 36134329,
|
||||||
|
"minutes": 46
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`)
|
||||||
|
start := apiTimeTrackerEntry{}
|
||||||
|
err = json.Unmarshal(trackerStart, &start)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else {
|
||||||
|
if start.TimeTrackerHolder.TrackingTimeEntry == nil {
|
||||||
|
t.Error("expected not nil, but is not")
|
||||||
|
} else {
|
||||||
|
if start.TimeTrackerHolder.TrackingTimeEntry.ID != 36135322 {
|
||||||
|
t.Error("bad unmarshal?")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if start.TimeTrackerHolder.StoppedTimeEntry == nil {
|
||||||
|
t.Error("expected not nil, but is nil")
|
||||||
|
} else {
|
||||||
|
if start.TimeTrackerHolder.StoppedTimeEntry.ID != 36134329 {
|
||||||
|
t.Error("bad unmarshal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,6 +35,7 @@ func (m model) updateForm(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
projectID := m.formData.form.GetString("project")
|
projectID := m.formData.form.GetString("project")
|
||||||
description := m.formData.form.GetString("description")
|
description := m.formData.form.GetString("description")
|
||||||
minutes := m.formData.form.GetString("minutes")
|
minutes := m.formData.form.GetString("minutes")
|
||||||
|
tracker := m.formData.form.GetBool("tracker")
|
||||||
|
|
||||||
minutesInt, err1 := strconv.ParseInt(minutes, 10, 64)
|
minutesInt, err1 := strconv.ParseInt(minutes, 10, 64)
|
||||||
serviceIDInt, err2 := strconv.ParseInt(serviceID, 10, 64)
|
serviceIDInt, err2 := strconv.ParseInt(serviceID, 10, 64)
|
||||||
@@ -45,14 +46,27 @@ func (m model) updateForm(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|||||||
m.tuiMode = MODE_CAL
|
m.tuiMode = MODE_CAL
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
err := m.miteAPI.AddTimeEntry(m.dest.Format(time.DateOnly), int(minutesInt), description, int(projectIDInt), int(serviceIDInt))
|
id, err := m.miteAPI.AddTimeEntry(m.dest.Format(time.DateOnly), int(minutesInt), description, int(projectIDInt), int(serviceIDInt))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
m.statusBarMessage = err.Error()
|
m.statusBarMessage = err.Error()
|
||||||
m.tuiMode = MODE_CAL
|
m.tuiMode = MODE_CAL
|
||||||
} else {
|
} else {
|
||||||
m.statusBarMessage = "Successfully logged time"
|
if tracker {
|
||||||
m.tuiMode = MODE_CAL
|
_, _, err = m.miteAPI.StartTimeTracker(id)
|
||||||
return m, m.fetchMiteData()
|
if err != nil {
|
||||||
|
m.statusBarMessage = err.Error()
|
||||||
|
m.tuiMode = MODE_CAL
|
||||||
|
} else {
|
||||||
|
m.statusBarMessage = "Successfully logged time and started tracker"
|
||||||
|
m.tuiMode = MODE_CAL
|
||||||
|
return m, m.fetchMiteData()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
m.statusBarMessage = "Successfully logged time"
|
||||||
|
m.tuiMode = MODE_CAL
|
||||||
|
return m, m.fetchMiteData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,38 +115,51 @@ func (m model) buildForm() *huh.Form {
|
|||||||
Key("project").
|
Key("project").
|
||||||
Title("Project").
|
Title("Project").
|
||||||
Options(projOptions...).
|
Options(projOptions...).
|
||||||
Height(10)
|
Height(6)
|
||||||
|
|
||||||
|
description := huh.NewText().
|
||||||
|
Key("description").
|
||||||
|
Title("description").
|
||||||
|
Validate(func(s string) error {
|
||||||
|
if s == "" {
|
||||||
|
return errors.New("must enter a description")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
|
defMinutes := "0"
|
||||||
|
minutes := huh.NewInput().
|
||||||
|
Key("minutes").
|
||||||
|
CharLimit(5).
|
||||||
|
Validate(
|
||||||
|
func(s string) error {
|
||||||
|
h, err := strconv.ParseInt(s, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if h < 0 {
|
||||||
|
return errors.New("must be positive")
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}).
|
||||||
|
Title("Minutes").
|
||||||
|
Value(&defMinutes)
|
||||||
|
|
||||||
|
confirmTracker := huh.NewConfirm().
|
||||||
|
Key("tracker").
|
||||||
|
Affirmative("Yes").
|
||||||
|
Negative("No").
|
||||||
|
Title("Start tracker")
|
||||||
|
|
||||||
form := huh.NewForm(
|
form := huh.NewForm(
|
||||||
huh.NewGroup(
|
huh.NewGroup(
|
||||||
pl,
|
pl,
|
||||||
sl,
|
sl,
|
||||||
|
description,
|
||||||
),
|
),
|
||||||
huh.NewGroup(
|
huh.NewGroup(
|
||||||
huh.NewText().
|
minutes,
|
||||||
Key("description").
|
confirmTracker,
|
||||||
Title("description").
|
|
||||||
Validate(func(s string) error {
|
|
||||||
if s == "" {
|
|
||||||
return errors.New("must enter a description")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}),
|
|
||||||
huh.NewInput().
|
|
||||||
Key("minutes").
|
|
||||||
CharLimit(5).
|
|
||||||
Validate(
|
|
||||||
func(s string) error {
|
|
||||||
h, err := strconv.ParseInt(s, 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if h < 0 {
|
|
||||||
return errors.New("must be positive")
|
|
||||||
}
|
|
||||||
return err
|
|
||||||
}).
|
|
||||||
Title("Minutes"),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
return form
|
return form
|
||||||
|
|||||||
Reference in New Issue
Block a user