Documentation
¶
Index ¶
- type CMD_FLAG
- type ConfigVals
- type DbType
- type FullUserQuery
- type ICliContext
- type ICommand
- type IFlagParser
- type IQueryingCommand
- type IRepository
- type IServerContext
- type ITodoCollection
- type InstanceType
- type ItemIdAlreadyExistsError
- type ItemIdNotFoundError
- type ItemNotAddedToPriorityListError
- type ItemsList
- type ListOption
- type ListType
- type NegativeParentIdError
- type PriorityLevel
- type PriorityList
- type PriorityOption
- type PriorityQueue
- type QueryType
- type ServerConfigVals
- type SimpleList
- type TagAlreadyExistsError
- type TodoItem
- type UserQueryElement
- type UserQueryOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CMD_FLAG ¶
type CMD_FLAG string
Flags used throughout the system
const ( All CMD_FLAG = "-a" Body CMD_FLAG = "-b" Child CMD_FLAG = "-c" Date CMD_FLAG = "-d" Creation CMD_FLAG = "-e" // e for existence! Finished CMD_FLAG = "-f" // item complete ItmId CMD_FLAG = "-i" Mode CMD_FLAG = "-m" Next CMD_FLAG = "-n" Parent CMD_FLAG = "-p" Tag CMD_FLAG = "-t" ChangeBody CMD_FLAG = "-B" //append or replace ChangeParent CMD_FLAG = "-C" ChangedDeadline CMD_FLAG = "-D" MarkComplete CMD_FLAG = "-F" ChangeMode CMD_FLAG = "-M" ChangeTag CMD_FLAG = "-T" //append, replace, or remove AppendMode CMD_FLAG = "--append" ReplaceMode CMD_FLAG = "--replace" // Modifies the behaviour of the -n flag (next) in get command. // Instead of next by priority, it's next by date. DateMode CMD_FLAG = "--date" )
type ConfigVals ¶
type ConfigVals struct {
Args []string
Client http.Client
TodoRepo IRepository
Instance InstanceType
RemoteUrl string
DateLayout string
NowString string
Conn string
MaxLen int
IntDigits int
TagDelim string
Parser IFlagParser
}
type DbType ¶
type DbType string
Differnt kinds of supported RDBMS
const (
Sqlite DbType = "sqlite3"
)
type FullUserQuery ¶
type FullUserQuery struct {
QueryOptions []UserQueryOption `json:"qryOpts"`
QueryData TodoItem `json:"qryData"`
}
Single query object to combine query options alongside the relevant query data. Ex. ById is the query option and '8' is the query data
type ICliContext ¶
type ICliContext interface {
SetupCliContext(args []string)
SetupFlagParser()
GetCommand() (ICommand, error)
}
passed to different commands to run cli
type ICommand ¶
type ICommand interface {
ParseInput() error
Run(io.Writer) error
BuildItemFromInput() (TodoItem, error)
}
Sets out the methods implemented by commands that the user can execute
type IFlagParser ¶
type IQueryingCommand ¶
type IQueryingCommand interface {
DetermineQueryType(qType QueryType) ([]UserQueryOption, error)
}
type IRepository ¶
type IRepository interface {
GetAll() ([]TodoItem, error)
GetWhere(query FullUserQuery) ([]TodoItem, error)
Add(itm *TodoItem) (int64, error)
UpdateWhere(srchQry, edtQry FullUserQuery) (int, error)
}
Defines methods used to interact with data storage
type IServerContext ¶
type IServerContext interface {
SetupServerContext(conf ServerConfigVals)
Serve()
}
type ITodoCollection ¶
type ITodoCollection interface {
Add(itm TodoItem) error
Delete(id int) error
Update(itm *TodoItem) error
GetById(id int) (*TodoItem, error)
GetNext() (*TodoItem, error)
}
Defines common behaviour of different collection types
type InstanceType ¶
type InstanceType int
Denotes app instance's use of local, remote, or multiple storage options; determined via an environment variable
const ( Local InstanceType = iota Remote Multiple // allows for simultaneous use of multiple storage options - all local, all remote, or a mix. )
type ItemIdAlreadyExistsError ¶
type ItemIdAlreadyExistsError struct{}
func (*ItemIdAlreadyExistsError) Error ¶
func (e *ItemIdAlreadyExistsError) Error() string
type ItemIdNotFoundError ¶
type ItemIdNotFoundError struct{}
func (*ItemIdNotFoundError) Error ¶
func (i *ItemIdNotFoundError) Error() string
type ItemNotAddedToPriorityListError ¶
type ItemNotAddedToPriorityListError struct{}
func (*ItemNotAddedToPriorityListError) Error ¶
func (e *ItemNotAddedToPriorityListError) Error() string
type ItemsList ¶
type ItemsList struct {
List ITodoCollection
LType ListType
}
ItemsList is a container for specific implementations of ITodoCollection
func NewItemsList ¶
func NewItemsList(o ListOption) *ItemsList
type ListOption ¶
type ListOption func(lst *ItemsList)
func WithListType ¶
func WithListType(lt ListType) ListOption
type NegativeParentIdError ¶
type NegativeParentIdError struct{}
func (*NegativeParentIdError) Error ¶
func (e *NegativeParentIdError) Error() string
type PriorityLevel ¶
type PriorityLevel int
const ( None PriorityLevel = iota Low Medium High DateBased )
type PriorityList ¶
type PriorityList struct {
DateMode bool
List PriorityQueue
}
PriorityList is an implementation of ITodoCollection
func (*PriorityList) Add ¶
func (pl *PriorityList) Add(itm TodoItem) error
Add item to queue - ITodoCollection implementation
func (*PriorityList) Delete ¶
func (pl *PriorityList) Delete(id int) error
Delete item from queue - ITodoCollection implementation
func (*PriorityList) GetNext ¶
func (pl *PriorityList) GetNext() (*TodoItem, error)
Get next item from queue based on priority - ITodoCollection implementation
func (*PriorityList) Update ¶
func (pl *PriorityList) Update(itm *TodoItem) error
Update existing queue item - ITodoCollection implementation
type PriorityOption ¶
type PriorityOption func(itm *TodoItem)
Function used in TodoItem initialisation to set PriorityLevel
func WithDateBasedPriority ¶
func WithDateBasedPriority(date, dateFormat string) PriorityOption
func WithPriorityLevel ¶
func WithPriorityLevel(p PriorityLevel) PriorityOption
type PriorityQueue ¶
PriorityQueue implements heap interface methods
func NewPriorityQueue ¶
func NewPriorityQueue() *PriorityQueue
NewPriorityQueue constructor for PriorityQueue
func (PriorityQueue) Less ¶
func (pq PriorityQueue) Less(a, b int) bool
Less required by heap.Interface
func (*PriorityQueue) Pop ¶
func (pq *PriorityQueue) Pop() interface{}
Pop required by heap.Interface
func (*PriorityQueue) Push ¶
func (pq *PriorityQueue) Push(todoItm interface{})
Push required by heap.Interface
func (*PriorityQueue) Swap ¶
func (pq *PriorityQueue) Swap(a, b int)
Swap required by heap.Interface
type QueryType ¶
type QueryType int
Enum for basic CRUD operations. Used to switch on to get relevant SQL.
type ServerConfigVals ¶
type ServerConfigVals struct {
Repo IRepository
Conn string
DateFormat string
PriorityList *PriorityList
RunPriorityList bool
Port int
}
type SimpleList ¶
SimpleList is an implementation of ITodoCollection
func NewSimpleList ¶
func NewSimpleList() *SimpleList
func (*SimpleList) Add ¶
func (sl *SimpleList) Add(itm TodoItem) error
func (*SimpleList) Delete ¶
func (sl *SimpleList) Delete(id int) error
func (*SimpleList) GetNext ¶
func (sl *SimpleList) GetNext() (*TodoItem, error)
func (*SimpleList) Update ¶
func (sl *SimpleList) Update(itm *TodoItem) error
type TagAlreadyExistsError ¶
type TagAlreadyExistsError struct{}
func (*TagAlreadyExistsError) Error ¶
func (e *TagAlreadyExistsError) Error() string
type TodoItem ¶
type TodoItem struct {
Id int `json:"itemId"`
ParentId int `json:"parentId"`
IsChild bool `json:"isChild"`
CreationDate time.Time `json:"creationDate"`
Deadline time.Time `json:"deadlineDate"`
Priority PriorityLevel `json:"priority"`
Body string `json:"itemText"`
IsComplete bool `json:"isComplete"`
ChildItems map[int]struct{} `json:"children"` // map of TodoItem.id with empty struct
Tags map[string]struct{} `json:"tags"`
Index int // for the implementation of a priority list
}
func NewTodoItem ¶
func NewTodoItem(p PriorityOption) *TodoItem
NewTodoItem constructor initialises maps
func (*TodoItem) AddChildItem ¶
func (*TodoItem) RemoveChildItem ¶
func (*TodoItem) RemoveParent ¶
type UserQueryElement ¶
type UserQueryElement int
Enums describing the different item attributes that the user can query & edit
const ( ById UserQueryElement = iota ByChildId ByParentId ByTag ByBody ByNextPriority ByNextDate ByDeadline ByCreationDate ByReplacement ByAppending ByCompletion )
type UserQueryOption ¶
type UserQueryOption struct {
Elem UserQueryElement `json:"elem"`
UpperBoundDate time.Time `json:"upperBound"`
}
Wrapper for a single UserQueryElement and a SetUpperDateBound function to allow for date range searching