Documentation ¶
Overview ¶
Package taskpoet is the main worker library
Index ¶
- Constants
- Variables
- func APIClient(client *Poet) gin.HandlerFunc
- func AddPlugin(name string, creator Creator)
- func CheckUniqueStringSlice(target []string) bool
- func EffortImpactText(code int) string
- func FilterHidden(p *FilterParams, task Task) bool
- func FilterRegex(p *FilterParams, task Task) bool
- func MustParseDuration(s string) time.Duration
- func NewRouter(rc *RouterConfig) *gin.Engine
- func ParseDuration(s string) (time.Duration, error)
- func WithPresent(t *time.Time) func(*Calendar)
- func WithStatusChannel(s chan ProgressStatus) func(*ProgressModel)
- func WithWeights(w weightMap) func(*Curator)
- type APITaskResponse
- type ByCompleted
- type ByDue
- type ByUrgency
- type Calendar
- type Comment
- type Creator
- type Curator
- type EffortImpact
- type Filter
- type FilterParams
- type Option
- type Pagination
- type Poet
- type ProgressModel
- type ProgressStatus
- type RecurringTask
- type RecurringTasks
- type RouterConfig
- type Rows
- type Synonym
- type TWAnnotation
- type TWTime
- type TableOpts
- type Task
- type TaskOption
- func WithAdded(d *time.Time) TaskOption
- func WithChildren(c []string) TaskOption
- func WithCompleted(d *time.Time) TaskOption
- func WithDescription(d string) TaskOption
- func WithDue(d *time.Time) TaskOption
- func WithEffortImpact(e EffortImpact) TaskOption
- func WithHideUntil(d *time.Time) TaskOption
- func WithID(i string) TaskOption
- func WithParents(p []string) TaskOption
- func WithTags(s []string) TaskOption
- func WithTaskWarriorTask(twItem TaskWarriorTask) TaskOption
- type TaskPlugin
- type TaskService
- type TaskServiceOp
- func (svc *TaskServiceOp) Add(t *Task) (*Task, error)
- func (svc *TaskServiceOp) AddChild(p, c *Task) error
- func (svc *TaskServiceOp) AddOrEditSet(tasks []Task) error
- func (svc *TaskServiceOp) AddParent(c, p *Task) error
- func (svc *TaskServiceOp) AddSet(t Tasks) error
- func (svc *TaskServiceOp) Complete(t *Task) error
- func (svc *TaskServiceOp) Describe(t *Task) error
- func (svc *TaskServiceOp) Edit(t *Task) (*Task, error)
- func (svc *TaskServiceOp) EditSet(tasks []Task) error
- func (svc *TaskServiceOp) GetIDsByPrefix(prefix string) ([]string, error)
- func (svc *TaskServiceOp) GetPlugins() (map[string]Creator, error)
- func (svc *TaskServiceOp) GetStatePaths() []string
- func (svc *TaskServiceOp) GetStates() []string
- func (svc *TaskServiceOp) GetWithExactPath(path []byte) (*Task, error)
- func (svc *TaskServiceOp) GetWithID(id, pluginID, state string) (*Task, error)
- func (svc *TaskServiceOp) GetWithPartialID(partialID, pluginID, state string) (*Task, error)
- func (svc *TaskServiceOp) List(prefix string) (Tasks, error)
- func (svc *TaskServiceOp) Log(t *Task, d *Task) (*Task, error)
- func (svc *TaskServiceOp) Purge(t *Task) error
- func (svc *TaskServiceOp) SyncPlugin(tp TaskPlugin) error
- type TaskWarriorTask
- type TaskWarriorTasks
- type Tasks
Constants ¶
const ( // XS is extra small XS int = 1 // SM is small SM int = 3 // MD is medium MD int = 5 // LG is large LG int = 10 )
const DefaultPluginID string = "builtin"
DefaultPluginID is just the string used as the built in plugin default
Variables ¶
var TaskPlugins = map[string]Creator{}
TaskPlugins isi the creator map
Functions ¶
func APIClient ¶ added in v0.0.2
func APIClient(client *Poet) gin.HandlerFunc
APIClient is an API Client
func CheckUniqueStringSlice ¶ added in v0.0.2
CheckUniqueStringSlice checks if this is a unique thing
func EffortImpactText ¶ added in v0.0.2
EffortImpactText returns text from the code
func FilterHidden ¶ added in v0.0.10
func FilterHidden(p *FilterParams, task Task) bool
FilterHidden removes items that are still hidden
func FilterRegex ¶ added in v0.0.10
func FilterRegex(p *FilterParams, task Task) bool
FilterRegex removes items not matching a given regex
func MustParseDuration ¶ added in v0.1.0
MustParseDuration parses a duration or panics
func NewRouter ¶ added in v0.0.2
func NewRouter(rc *RouterConfig) *gin.Engine
NewRouter returns a new http router
func ParseDuration ¶
ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d", "w".
func WithPresent ¶ added in v0.2.2
WithPresent sets the present time to an arbitrary datetime
func WithStatusChannel ¶ added in v0.1.0
func WithStatusChannel(s chan ProgressStatus) func(*ProgressModel)
WithStatusChannel sets the channel on a new object
func WithWeights ¶ added in v0.3.1
func WithWeights(w weightMap) func(*Curator)
WithWeights sets the weights in a curator at build time
Types ¶
type APITaskResponse ¶ added in v0.0.2
type APITaskResponse struct { Pagination Pagination `json:"pagination"` Data Tasks `json:"data"` }
APITaskResponse is the task response
type ByCompleted ¶ added in v0.1.0
type ByCompleted Tasks
ByCompleted is the by completed date sorter
func (ByCompleted) Len ¶ added in v0.1.0
func (a ByCompleted) Len() int
func (ByCompleted) Less ¶ added in v0.1.0
func (a ByCompleted) Less(i, j int) bool
func (ByCompleted) Swap ¶ added in v0.1.0
func (a ByCompleted) Swap(i, j int)
type Calendar ¶ added in v0.2.2
type Calendar struct {
// contains filtered or unexported fields
}
Calendar is a little helper function that can work with synonym times
func NewCalendar ¶ added in v0.2.2
NewCalendar returns a new calendar object
type Comment ¶ added in v0.1.0
type Comment struct { Added time.Time `json:"added,omitempty"` Comment string `json:"comment,omitempty"` }
Comment is just a little comment/note on a task
type Curator ¶ added in v0.3.1
type Curator struct {
// contains filtered or unexported fields
}
Curator examines tasks and weights them, giving them a semi smart sense of urgency
func NewCurator ¶ added in v0.3.1
NewCurator returns a new Curator instance with functional options
type EffortImpact ¶ added in v0.1.0
type EffortImpact int
EffortImpact is the type for an effor/impact statement
const ( // EffortImpactUnset is undefined EI EffortImpactUnset EffortImpact = iota // EffortImpactHigh is the highest EffortImpactHigh // EffortImpactMedium is medium EffortImpactMedium // EffortImpactLow is low EffortImpactLow // EffortImpactAvoid means stay away! EffortImpactAvoid )
func (EffortImpact) Emoji ¶ added in v0.1.0
func (e EffortImpact) Emoji() string
Emoji returns a nice little visual queue for a given effort/impact statement
type Filter ¶ added in v0.0.10
type Filter func(*FilterParams, Task) bool
Filter is a filter function applied to a single task
type FilterParams ¶ added in v0.0.10
FilterParams are options for filtering tasks
type Option ¶ added in v0.0.10
Option helper for functional options with error reporting
func WithDatabasePath ¶ added in v0.0.10
WithDatabasePath gives the Poet a path to a database file
func WithNamespace ¶ added in v0.0.10
WithNamespace passes a namespace in to the new Poet object
func WithRecurringTasks ¶ added in v0.1.0
func WithRecurringTasks(r RecurringTasks) Option
WithRecurringTasks sets the recurring tasks for a poet
func WithStyling ¶ added in v0.2.0
WithStyling gives the poet a certain style at create
type Pagination ¶ added in v0.0.2
type Pagination struct { Limit uint `json:"limit"` Page uint `json:"page"` Sort string `json:"sort"` HasMore bool `json:"hasmore"` }
Pagination is the pagination yo
type Poet ¶ added in v0.0.10
type Poet struct { DB *bolt.DB Namespace string Default Task Task TaskService RecurringTasks RecurringTasks // contains filtered or unexported fields }
Poet is the main operator for this whole thing
func (Poet) CompleteIDsWithPrefix ¶ added in v0.1.0
CompleteIDsWithPrefix returns a list of ids matching the given prefix and autocomplete pattern
func (*Poet) ImportTaskWarrior ¶ added in v0.1.0
func (p *Poet) ImportTaskWarrior(ts TaskWarriorTasks, c chan ProgressStatus) (int, error)
ImportTaskWarrior imports a set of TaskWarrior items and returns the number it imported, and an optional error
type ProgressModel ¶ added in v0.1.0
type ProgressModel struct {
// contains filtered or unexported fields
}
ProgressModel represents our fancy little progress bar
func NewProgressBar ¶ added in v0.1.0
func NewProgressBar(options ...func(*ProgressModel)) ProgressModel
NewProgressBar returns a new progress bar
func (ProgressModel) Init ¶ added in v0.1.0
func (m ProgressModel) Init() tea.Cmd
Init satisfies the model interface
func (ProgressModel) View ¶ added in v0.1.0
func (m ProgressModel) View() string
View satisfies the model interface
type ProgressStatus ¶ added in v0.1.0
ProgressStatus is a helper to show a progress bar on a bunch of item things
type RecurringTask ¶ added in v0.1.0
type RecurringTask struct { Description string `yaml:"description"` Frequency time.Duration `yaml:"frequency"` }
RecurringTask is a task that recurs
type RecurringTasks ¶ added in v0.1.0
type RecurringTasks []RecurringTask
RecurringTasks represents multiple RecurringTask items
type RouterConfig ¶ added in v0.0.2
RouterConfig configures the router
type Synonym ¶ added in v0.2.2
type Synonym string
Synonym is a helper for a relative time period
var ( // Now is exactly now Now Synonym = "now" // Today is the beginning of the day today Today Synonym = "today" // EndOfday is the current date, end of the day EndOfday Synonym = "endofday" // Tomorrow is the next day, beginning of the day Tomorrow Synonym = "tomorrow" // StartOfDay is the current date, beginning of the day StartOfDay Synonym = "startofday" // Yesterday is the previous day, beginning of the day Yesterday Synonym = "yesterday" // StartOfYear is the start of next year, beginning of day StartOfYear Synonym = "startofyear" // EndOfYear is the end of this year, end of day EndOfYear Synonym = "endofyear" // Later is a date faaaaar away Later Synonym = "later" // EOM is the last day of the current month, end of the day EOM Synonym = "eom" // EOCM is the end of the current month, end of the day EOCM Synonym = "eocm" // SOM is the start of the next month, beginning of the day SOM Synonym = "som" // SOCM is the start of the current month, beginning of the day SOCM Synonym = "socm" // SOW is the start of the next week, beginning of the day SOW Synonym = "sow" // SOCW is the start of the current week, beginning of the day SOCW Synonym = "socw" // EOW is the end of the week, Saturday, beginning of the day EOW Synonym = "eow" // EOCW is the end of the week, Saturday, beginning of the day EOCW Synonym = "eocw" // SOWW is the start of the work week, beginning of the day SOWW Synonym = "soww" // EOWW is the end of the work week, end of the day EOWW Synonym = "eoww" /* Nth represents the n'th day of the month */ // nolint First Synonym = "1st" // nolint Second Synonym = "2nd" // nolint Third Synonym = "3rd" // nolint Fourth Synonym = "4th" // nolint Fifth Synonym = "5th" // nolint Sixth Synonym = "6th" // nolint Seventh Synonym = "7th" // nolint Eight Synonym = "8th" // nolint Ninth Synonym = "9th" // nolint Tenth Synonym = "10th" // nolint Eleventh Synonym = "11th" // nolint Twelfth Synonym = "12th" // nolint Thirteenth Synonym = "13th" // nolint Fourteenth Synonym = "14th" // nolint Fifthteenth Synonym = "15th" // nolint Sixteenth Synonym = "16th" // nolint Seventeenth Synonym = "17th" // nolint Eightteenth Synonym = "18th" // nolint Nineteenth Synonym = "19th" // nolint Twentith Synonym = "20th" // nolint TwentyFirst Synonym = "21st" // nolint TwentySecond Synonym = "22nd" // nolint TwentyThird Synonym = "23rd" // nolint TwentyFourth Synonym = "24th" // nolint TwentyFifth Synonym = "25th" // nolint TwentySixth Synonym = "26th" // nolint TwentySeventh Synonym = "27th" // nolint TwentyEith Synonym = "28th" // nolint TwentyNinth Synonym = "29th" // nolint Thirtyith Synonym = "30th" // nolint ThirtyFirst Synonym = "31st" // nolint January Synonym = "january" // nolint February Synonym = "februrary" // nolint March Synonym = "march" // nolint April Synonym = "april" // nolint May Synonym = "may" // nolint June Synonym = "june" // nolint July Synonym = "july" // nolint August Synonym = "august" // nolint September Synonym = "september" // nolint October Synonym = "october" // nolint November Synonym = "november" // nolint December Synonym = "december" // nolint Monday Synonym = "monday" // nolint Tuesday Synonym = "tuesday" // nolint Wednesday Synonym = "wednesday" // nolint Thursday Synonym = "thursday" // nolint Friday Synonym = "friday" // nolint Saturday Synonym = "saturday" // nolint Sunday Synonym = "sunday" // nolint )
func (Synonym) Description ¶ added in v0.3.0
Description returns a description for a Synonym
type TWAnnotation ¶ added in v0.1.0
type TWAnnotation struct { Entry *TWTime `json:"entry,omitempty"` Description string `json:"description,omitempty"` }
TWAnnotation is a TaskWarrior Annotation
type TWTime ¶ added in v0.1.0
TWTime is the format that TaskWarrior uses for timestamps
func (TWTime) MarshalJSON ¶ added in v0.1.0
MarshalJSON writes a quoted string in the custom format
func (*TWTime) UnmarshalJSON ¶ added in v0.1.0
UnmarshalJSON Parses the json string in the custom format
type TableOpts ¶ added in v0.1.0
type TableOpts struct { Prefix string FilterParams FilterParams Filters []Filter Columns []string SortBy any }
TableOpts defines the data displayed in a table
type Task ¶
type Task struct { ID string `json:"id"` PluginID string `json:"plugin_id"` Description string `json:"description"` Due *time.Time `json:"due,omitempty"` HideUntil *time.Time `json:"hide_until,omitempty"` // HideUntil is similar to 'wait' in taskwarrior CancelAfter *time.Time `json:"cancel_after,omitempty"` // CancelAfter is similar to 'until' in taskwarrior Completed *time.Time `json:"completed,omitempty"` Reviewed *time.Time `json:"reviewed,omitempty"` Deleted *time.Time `json:"deleted,omitempty"` Added time.Time `json:"added,omitempty"` EffortImpact EffortImpact `json:"effort_impact"` Children []string `json:"children,omitempty"` Parents []string `json:"parents,omitempty"` Tags []string `json:"tags,omitempty"` Comments []Comment `json:"comments,omitempty"` Project string `json:"project,omitempty"` Urgency float64 `json:"urgency:omitempty"` }
Task is the actual task item
func MustNewTask ¶ added in v0.1.0
func MustNewTask(description string, options ...TaskOption) *Task
MustNewTask returns a task or panics
func NewTask ¶ added in v0.1.0
func NewTask(desc string, options ...TaskOption) (*Task, error)
NewTask returns a new task given functional options
func (*Task) DetectKeyPath ¶ added in v0.0.2
DetectKeyPath finds the key path for a given task
type TaskOption ¶ added in v0.1.0
type TaskOption func(*Task)
TaskOption is a functional option for a new Task
func WithAdded ¶ added in v0.3.1
func WithAdded(d *time.Time) TaskOption
WithAdded sets the added date on create
func WithChildren ¶ added in v0.1.0
func WithChildren(c []string) TaskOption
WithChildren set the children of a task
func WithCompleted ¶ added in v0.1.0
func WithCompleted(d *time.Time) TaskOption
WithCompleted sets the completed date on create
func WithDescription ¶ added in v0.1.0
func WithDescription(d string) TaskOption
WithDescription sets the description on create
func WithDue ¶ added in v0.1.0
func WithDue(d *time.Time) TaskOption
WithDue sets the due date on create
func WithEffortImpact ¶ added in v0.1.0
func WithEffortImpact(e EffortImpact) TaskOption
WithEffortImpact sets the impact statement on create
func WithHideUntil ¶ added in v0.1.0
func WithHideUntil(d *time.Time) TaskOption
WithHideUntil sets the hide until on create
func WithParents ¶ added in v0.1.0
func WithParents(p []string) TaskOption
WithParents set the parents of a task
func WithTags ¶ added in v0.1.0
func WithTags(s []string) TaskOption
WithTags sets the tags on create
func WithTaskWarriorTask ¶ added in v0.1.0
func WithTaskWarriorTask(twItem TaskWarriorTask) TaskOption
WithTaskWarriorTask imports a task from a task warrior task
type TaskPlugin ¶ added in v0.0.2
TaskPlugin describes what a plugin is
type TaskService ¶
type TaskService interface { // This should replace New, and Log Add(t *Task) (*Task, error) AddSet(t Tasks) error // Helper for adding Parent AddParent(c, p *Task) error AddChild(p, c *Task) error // Describe something Describe(t *Task) error // Edit a Task entry Edit(t *Task) (*Task, error) EditSet(t []Task) error // Should we use this instead of above funcs? AddOrEditSet(tasks []Task) error // Purge completely removes a task out of the DB Purge(t *Task) error // Complete a task Complete(t *Task) error // Sweet lord, this gettin' confusin' Drew GetPlugins() (map[string]Creator, error) SyncPlugin(TaskPlugin) error // States of a Task GetStates() []string GetStatePaths() []string // Just a little helper function to add and immediately mark as completed Log(t, d *Task) (*Task, error) // This on prolly needs work List(prefix string) (Tasks, error) /* Path Conventions /${state}/${plugin-id}/${id} $state -> Active or Completed $plugin-id -> Could be 'default'...or ”...or 'plugin-1' $id -> Unique identifier $plugin-id/$id should be unique together. Think things like: gitlab.com/ISSUE-2 gitlab.local.io/ISSUE-2 */ // New way to get stuff GetWithID(id, pluginID, state string) (*Task, error) GetWithPartialID(partialID, pluginID, state string) (*Task, error) GetWithExactPath(path []byte) (*Task, error) // Old way to get stuff, delete soon GetIDsByPrefix(prefix string) ([]string, error) }
TaskService is the interface to tasks...we'll delete this junk
type TaskServiceOp ¶
type TaskServiceOp struct {
// contains filtered or unexported fields
}
TaskServiceOp is the TaskService Operator
func (*TaskServiceOp) Add ¶ added in v0.0.2
func (svc *TaskServiceOp) Add(t *Task) (*Task, error)
Add adds a new task
func (*TaskServiceOp) AddChild ¶ added in v0.0.2
func (svc *TaskServiceOp) AddChild(p, c *Task) error
AddChild adds a child to a parent
func (*TaskServiceOp) AddOrEditSet ¶ added in v0.0.2
func (svc *TaskServiceOp) AddOrEditSet(tasks []Task) error
AddOrEditSet adds or edits a set of tasks
func (*TaskServiceOp) AddParent ¶ added in v0.0.2
func (svc *TaskServiceOp) AddParent(c, p *Task) error
AddParent adds a parent to a child command
func (*TaskServiceOp) AddSet ¶ added in v0.0.2
func (svc *TaskServiceOp) AddSet(t Tasks) error
AddSet adds a task set
func (*TaskServiceOp) Complete ¶
func (svc *TaskServiceOp) Complete(t *Task) error
Complete marks a task as completed
func (*TaskServiceOp) Describe ¶ added in v0.0.2
func (svc *TaskServiceOp) Describe(t *Task) error
Describe describes a task
func (*TaskServiceOp) Edit ¶ added in v0.0.2
func (svc *TaskServiceOp) Edit(t *Task) (*Task, error)
Edit edits an existing task
func (*TaskServiceOp) EditSet ¶ added in v0.0.2
func (svc *TaskServiceOp) EditSet(tasks []Task) error
EditSet edits a single set of tasks
func (*TaskServiceOp) GetIDsByPrefix ¶
func (svc *TaskServiceOp) GetIDsByPrefix(prefix string) ([]string, error)
GetIDsByPrefix returns a list of ids matching the given prefix
func (*TaskServiceOp) GetPlugins ¶ added in v0.0.2
func (svc *TaskServiceOp) GetPlugins() (map[string]Creator, error)
GetPlugins returns all plugins
func (*TaskServiceOp) GetStatePaths ¶ added in v0.0.2
func (svc *TaskServiceOp) GetStatePaths() []string
GetStatePaths is each of the states with a / prefix i guess
func (*TaskServiceOp) GetStates ¶ added in v0.0.2
func (svc *TaskServiceOp) GetStates() []string
GetStates returns types of states
func (*TaskServiceOp) GetWithExactPath ¶ added in v0.0.2
func (svc *TaskServiceOp) GetWithExactPath(path []byte) (*Task, error)
GetWithExactPath returns a task from an exact path
func (*TaskServiceOp) GetWithID ¶ added in v0.0.2
func (svc *TaskServiceOp) GetWithID(id, pluginID, state string) (*Task, error)
GetWithID returns a task from an ID
func (*TaskServiceOp) GetWithPartialID ¶ added in v0.0.2
func (svc *TaskServiceOp) GetWithPartialID(partialID, pluginID, state string) (*Task, error)
GetWithPartialID returns using a partial id of the task
func (*TaskServiceOp) List ¶
func (svc *TaskServiceOp) List(prefix string) (Tasks, error)
List lists items under a given prefix
func (*TaskServiceOp) Log ¶
func (svc *TaskServiceOp) Log(t *Task, d *Task) (*Task, error)
Log is a Shortcut utility to add a new task, but a completed time of 'now'
func (*TaskServiceOp) Purge ¶ added in v0.1.0
func (svc *TaskServiceOp) Purge(t *Task) error
Purge removes a task from the database
func (*TaskServiceOp) SyncPlugin ¶ added in v0.0.2
func (svc *TaskServiceOp) SyncPlugin(tp TaskPlugin) error
SyncPlugin syncs a plugin or whatever
type TaskWarriorTask ¶ added in v0.1.0
type TaskWarriorTask struct { ID int64 `json:"id,omitempty"` Description string `json:"description,omitempty"` UUID string `json:"uuid,omitempty"` Status string `json:"status,omitempty"` Entry *TWTime `json:"entry,omitempty"` Modified *TWTime `json:"modified,omitempty"` Due *TWTime `json:"due,omitempty"` Wait *TWTime `json:"wait,omitempty"` End *TWTime `json:"end,omitempty"` Reviewed *TWTime `json:"reviewed,omitempty"` Until *TWTime `json:"until,omitempty"` Mask string `json:"mask,omitempty"` Urgency float64 `json:"urgency,omitempty"` Tags []string `json:"tags,omitempty"` Annotations []TWAnnotation `json:"annotations,omitempty"` }
TaskWarriorTask is a task from TaskWarrior
type TaskWarriorTasks ¶ added in v0.1.0
type TaskWarriorTasks []TaskWarriorTask
TaskWarriorTasks is multiple TaskWarriorTasks items
type Tasks ¶ added in v0.0.10
type Tasks []*Task
Tasks represents multiple Task items
func ApplyFilters ¶ added in v0.0.10
func ApplyFilters(tasks Tasks, p *FilterParams, filters ...Filter) Tasks
ApplyFilters applies a set of filters to a task list. Each record will be checked against each filter. The filters are applied in the order they are passed in.