core

package
v0.0.0-...-2f4f41e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GeminiConfig = &genai.GenerateContentConfig{
	ResponseMIMEType: "application/json",
	ResponseSchema:   geminiSchema,
}

Functions

func ListLists

func ListLists(lists []string, tab string) string

func RemoveIntFromSlice

func RemoveIntFromSlice(s []int, val int) []int

func Success

func Success(msg string)

func WithDefaultDB

func WithDefaultDB(fn func(db *DB) error) error

A utility function that simplifies the usage of the default database.

Types

type DB

type DB struct {
	BoltDB *bolt.DB
}

func InitDB

func InitDB(path string) (*DB, error)

Initialize the database. For testing purposes, a custom path can be provided, but it is recommended to use `os.UserConfigDir()`.

func InitDefaultDB

func InitDefaultDB() (*DB, error)

Open DB located in user's default config dir.

func (*DB) CleanAllLists

func (db *DB) CleanAllLists() (int, error)

Clean up completed tasks in all lists

func (*DB) CleanCurrentList

func (db *DB) CleanCurrentList() (int, error)

Clean up completed tasks in the current list

func (*DB) CleanLists

func (db *DB) CleanLists(names []string) (int, error)

Clean up completed tasks in the specified lists

func (*DB) Close

func (db *DB) Close() error

func (*DB) DeleteAllLists

func (db *DB) DeleteAllLists() error

remove all lists

func (*DB) DeleteLists

func (db *DB) DeleteLists(names []string) error

remove the list with the given name

func (*DB) GetAPIKey

func (db *DB) GetAPIKey() (string, error)

func (*DB) GetCurrentListName

func (db *DB) GetCurrentListName() (string, error)

get the name of the currently active list

func (*DB) GetInfo

func (db *DB) GetInfo() (map[string]ListInfo, error)

gets the metadata for every list stored in the database

func (*DB) GetKmapPath

func (db *DB) GetKmapPath() (string, error)

func (*DB) GetList

func (db *DB) GetList(name string) (List, error)

get a specific list by name

func (*DB) ListExists

func (db *DB) ListExists(name string) (bool, error)

func (*DB) RenameList

func (db *DB) RenameList(oldName, newName string) error

Rename the list with the oldName to the newName. Since bbolt does not support renaming buckets, we need to completely recreate the bucket with the new name.

func (*DB) SaveList

func (db *DB) SaveList(list List) error

save the given list

func (*DB) SetAPIKey

func (db *DB) SetAPIKey(apiKey string) error

func (*DB) SetCurrentListName

func (db *DB) SetCurrentListName(name string) error

set the name of the currently active list

func (*DB) SetKmapPath

func (db *DB) SetKmapPath(path string) error

type List

type List struct {
	Info    ListInfo
	TaskIds []int
	Tasks   map[int]*Task
	UsedIds map[int]struct{}
}

func NewList

func NewList(name string) List

func (*List) AddNewTask

func (l *List) AddNewTask(description string, done bool) (int, error)

add a new task to the list and update meta data returns the id of the newly created task

func (*List) AddTask

func (l *List) AddTask(task Task) error

add a task to the list.

func (*List) EditTaskDescription

func (l *List) EditTaskDescription(taskId int, newDescription string) error

update the description of the task with the given id

func (*List) Insert

func (l *List) Insert(task Task, index int) error

insert a task after a certain index of the list.

func (*List) InsertNewTask

func (l *List) InsertNewTask(description string, index int) (int, error)

insert a new task into the list at the specified index and update meta data

func (*List) NewTask

func (l *List) NewTask(description string, done bool) (Task, error)

make new task with the given description and completion status without adding it to the list.

func (*List) RemoveTask

func (l *List) RemoveTask(taskId int) error

remove the task with the given id from the list and update meta data

func (*List) String

func (l *List) String() string

func (*List) ToggleCompletion

func (l *List) ToggleCompletion(taskId int) error

toggle the completion status of the task with the given id

type ListInfo

type ListInfo struct {
	Name       string
	NumDone    int
	NumPending int
	NumTasks   int
}

type Task

type Task struct {
	Id          int
	Description string
	Done        bool
}

func SplitByCompletion

func SplitByCompletion(list List) (completed, pending []*Task)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL