planner/plan/command/command.go

39 lines
748 B
Go
Raw Normal View History

2024-10-29 07:22:04 +01:00
package command
import (
"errors"
2024-12-27 11:20:32 +01:00
"go-mod.ewintr.nl/planner/plan/storage"
"go-mod.ewintr.nl/planner/sync/client"
2024-10-29 07:22:04 +01:00
)
const (
2024-12-27 11:20:32 +01:00
DateFormat = "2006-01-02"
TimeFormat = "15:04"
)
var (
ErrWrongCommand = errors.New("wrong command")
ErrInvalidArg = errors.New("invalid argument")
2024-10-29 07:22:04 +01:00
)
2025-01-13 09:13:48 +01:00
type Repositories interface {
Begin() (*storage.Tx, error)
LocalID(tx *storage.Tx) storage.LocalID
Sync(tx *storage.Tx) storage.Sync
Task(tx *storage.Tx) storage.Task
2025-01-19 10:56:03 +01:00
Schedule(tx *storage.Tx) storage.Schedule
2024-12-27 11:20:32 +01:00
}
type CommandArgs interface {
Parse(main []string, fields map[string]string) (Command, error)
}
2024-10-29 07:22:04 +01:00
type Command interface {
2025-01-13 09:13:48 +01:00
Do(repos Repositories, client client.Client) (CommandResult, error)
2024-12-29 09:32:49 +01:00
}
type CommandResult interface {
Render() string
2024-10-29 07:22:04 +01:00
}