Documentation
¶
Overview ¶
Package model provides describes the internal types and their behaviors
Index ¶
- Constants
- Variables
- func MakeSureFileExists(dataFilePath string, askUserInput bool) error
- type BaseStruct
- type Comment
- type Comments
- type Note
- func (note *Note) AddComment(text string) error
- func (note *Note) ExternalText(reminderData *ReminderData) (string, error)
- func (note *Note) GoogleCalendarEvent(repeatAnnuallyTagId int, repeatMonthlyTagId int, timezoneIANA string, ...) (*gc.Event, error)
- func (note *Note) RepeatType(repeatAnnuallyTagId int, repeatMonthlyTagId int) string
- func (note *Note) SafeExtText(tagger Tagger) (string, error)
- func (note *Note) SearchableText() (string, error)
- func (note *Note) Strings() ([]string, error)
- func (note *Note) ToggleMainFlag() error
- func (note *Note) Type() string
- func (note *Note) UpdateCompleteBy(text string) error
- func (note *Note) UpdateStatus(status NoteStatus, repeatTagIDs []int) error
- func (note *Note) UpdateSummary(text string) error
- func (note *Note) UpdateTags(tagIDs []int) error
- func (note *Note) UpdateText(text string) error
- type NoteStatus
- type Notes
- func (notes Notes) ExternalTexts(maxStrLen int, repeatAnnuallyTagId int, repeatMonthlyTagId int) []string
- func (c Notes) Len() int
- func (c Notes) Less(i, j int) bool
- func (notes Notes) OnlyMain() Notes
- func (notes Notes) PopulateTempDueDate()
- func (c Notes) Swap(i, j int)
- func (notes Notes) WithCompleteBy() Notes
- func (notes Notes) WithStatus(status NoteStatus) Notes
- func (notes Notes) WithTagIdAndStatus(tagID int, status NoteStatus) Notes
- type NotesByDueDate
- type Prompter
- type ReminderData
- func (rd *ReminderData) AddNoteComment(note *Note, text string) error
- func (rd *ReminderData) AskTagIds(tagIDs []int) []int
- func (rd *ReminderData) AutoBackup(gapSecs int64) (string, error)
- func (rd *ReminderData) CreateBackup() (string, error)
- func (rd *ReminderData) CreateDataFile(msg string) error
- func (rd *ReminderData) DisplayDataFile() error
- func (rd *ReminderData) FindNotesByTagId(tagID int, status NoteStatus) Notes
- func (rd *ReminderData) FindNotesByTagSlug(tagSlug string, status NoteStatus) Notes
- func (rd *ReminderData) GoogleCalendarEvents(timezoneIANA string) ([]*gc.Event, error)
- func (rd *ReminderData) ListTags() error
- func (rd *ReminderData) NewNoteRegistration(tagIDs []int) (*Note, error)
- func (rd *ReminderData) NewTagRegistration() (int, error)
- func (rd *ReminderData) NotesApprachingDueDate(view string) Notes
- func (rd *ReminderData) PrintNoteAndAskOptions(note *Note) string
- func (rd *ReminderData) PrintNotesAndAskOptions(notes Notes, display_mode string, tagID int, sortBy string) error
- func (rd *ReminderData) RegisterBasicTags() error
- func (rd *ReminderData) SearchNotes() error
- func (rd *ReminderData) SortedTagSlugs() []string
- func (rd *ReminderData) Stats() (string, error)
- func (rd *ReminderData) SyncCalendar(calOptions *calendar.Options) error
- func (rd *ReminderData) TagFromSlug(slug string) *Tag
- func (rd *ReminderData) TagIdsForGroup(group string) []int
- func (rd *ReminderData) TagsFromIds(tagIDs []int) []string
- func (rd *ReminderData) ToggleNoteMainFlag(note *Note) error
- func (rd *ReminderData) UpdateDataFile(msg string) error
- func (rd *ReminderData) UpdateNoteCompleteBy(note *Note, text string) error
- func (rd *ReminderData) UpdateNoteStatus(note *Note, status NoteStatus) error
- func (rd *ReminderData) UpdateNoteSummary(note *Note, text string) error
- func (rd *ReminderData) UpdateNoteTags(note *Note, tagIDs []int) error
- func (rd *ReminderData) UpdateNoteText(note *Note, text string) error
- type Tag
- type Tagger
- type Tags
- type User
Constants ¶
const EnableCalendar bool = true
Variables ¶
Functions ¶
func MakeSureFileExists ¶
MakeSureFileExists function makes sure that the dataFilePath exists.
Types ¶
type BaseStruct ¶
type BaseStruct struct { CreatedAt int64 `json:"created_at,omitempty"` UpdatedAt int64 `json:"updated_at,omitempty"` }
A BaseStruct provides set of common fields.
type Comment ¶
type Comment struct { Text string `json:"text"` BaseStruct }
A Comment is an update to a note.
Consider it a statement representing an action to be taken/done or just an update about the Note.
A comment belongs to a particular note, whereas a note can have multiple comments
type Comments ¶
type Comments []*Comment
A Comments is a slice of Comment objects.
By default it is sorted by its CreatedAt field
type Note ¶
type Note struct { Text string `json:"text"` Comments Comments `json:"comments"` Summary string `json:"summary"` // Status can be "pending", "done", or "suspended". // The "pending" status is special, and notes marked with it show up everywhere, whereas // the nodes marked with other status show up only under "Search" or their dedicated menu. Status NoteStatus `json:"status"` TagIds []int `json:"tag_ids"` IsMain bool `json:"is_main"` CompleteBy int64 `json:"complete_by"` BaseStruct // contains filtered or unexported fields }
A Note represents a task.
A note can be main or incidental. A note can be multiple tags, and a tag can be assocaited with mutiple notes.
func (*Note) AddComment ¶
AddComment adds a new comment to note.
func (*Note) ExternalText ¶
func (note *Note) ExternalText(reminderData *ReminderData) (string, error)
ExternalText prints a note with its tags slugs. This is used as final external reprensentation for display of a single note.
func (*Note) GoogleCalendarEvent ¶ added in v1.9.16
func (note *Note) GoogleCalendarEvent(repeatAnnuallyTagId int, repeatMonthlyTagId int, timezoneIANA string, tagger Tagger) (*gc.Event, error)
GoogleCalendarEvent converts a note to Google Calendar Event.
func (*Note) RepeatType ¶
RepeatType return - (Not-repeat), A (Annual-Repeat), or M (Monthly-Repeat) string representing repeat-type of the note
func (*Note) SafeExtText ¶ added in v1.9.22
SafeExtText prints a note with its tags slugs, but only the safe components. This is used as final external reprensentation for display of a single note to external services like Google Calendar.
func (*Note) SearchableText ¶
SearchableText provides string representation of the object. It is used while performing full text search on Text and Comments of a note.
func (*Note) Strings ¶
Strings provides basic string representation (as a slice of strings) of a note with each element of slice representing certain field of the note.
func (*Note) ToggleMainFlag ¶
ToggleMainFlag toggles note's main flag.
func (*Note) UpdateCompleteBy ¶
UpdateCompleteBy updates note's due date. The input is of the form DD-MM-YYYY or just DD-MM (with implicity value for year; either current or next). If input is "nil", the existing due date is cleared.
func (*Note) UpdateStatus ¶
func (note *Note) UpdateStatus(status NoteStatus, repeatTagIDs []int) error
UpdateStatus updates note's status ("done"/"pending"). Status of a note tag with repeat tag cannot be mared as "done".
func (*Note) UpdateSummary ¶
UpdateSummary updates note's summary. If input is "nil", the existing summary is cleared.
func (*Note) UpdateTags ¶
UpdateTags updates note's tags.
func (*Note) UpdateText ¶
UpdateText updates note's text. Once updated, the text cannot be made empty.
type NoteStatus ¶ added in v1.8.3
type NoteStatus string
const ( NoteStatus_Undefined NoteStatus = "undefined" // "pending": tasks which are yet to be done NoteStatus_Pending NoteStatus = "pending" // "suspended": tasks which are yet to be done but for now marked as suspended so as to keep them hidden at most of the places NoteStatus_Suspended NoteStatus = "suspended" // "done": tasks which have been completed (or not to be done) NoteStatus_Done NoteStatus = "done" )
type Notes ¶
type Notes []*Note
A Notes is a slice of Note objects.
By default it is sorted by its CreatedAt field.
func (Notes) ExternalTexts ¶
func (notes Notes) ExternalTexts(maxStrLen int, repeatAnnuallyTagId int, repeatMonthlyTagId int) []string
ExternalTexts returns display text (that is, external representation) of list of notes with width of each note is truncated to maxStrLen. It returns empty []string if there are no notes. Note: You may use repeatAnnuallyTagId and repeatMonthlyTagId as 0, if they are not required In the output: R means "repeat-type", C means "number of comments", S means "status", and D means "due date"
func (Notes) OnlyMain ¶
OnlyMain filters notes which are set as main. It returns empty Notes if no main notes is found.
func (Notes) PopulateTempDueDate ¶ added in v1.9.29
func (notes Notes) PopulateTempDueDate()
PopulateTempDueDate popultes tempDueDate field of note from its CompleteBy field.
func (Notes) WithCompleteBy ¶ added in v1.9.17
WithCompleteBy filters-in only notes with non-nil CompleteBy filed of the notes. It returns empty Notes if no matching Note is found (even when given status doesn't exist).
func (Notes) WithStatus ¶
func (notes Notes) WithStatus(status NoteStatus) Notes
WithStatus filters-in notes with given status (such as "pending" status). It returns empty Notes if no matching Note is found (even when given status doesn't exist).
func (Notes) WithTagIdAndStatus ¶
func (notes Notes) WithTagIdAndStatus(tagID int, status NoteStatus) Notes
WithTagIdAndStatus returns all notes with given tagID and given status. It returns empty Notes if no matching Note is found (even when given tagID or status doesn't exist).
type NotesByDueDate ¶
type NotesByDueDate []*Note
A NotesByDueDate is a slice of Note objects.
By default it is sorted by its CreatedAt field.
func (NotesByDueDate) Len ¶
func (c NotesByDueDate) Len() int
func (NotesByDueDate) Less ¶
func (c NotesByDueDate) Less(i, j int) bool
func (NotesByDueDate) Swap ¶
func (c NotesByDueDate) Swap(i, j int)
type ReminderData ¶
type ReminderData struct { User *User `json:"user"` Notes Notes `json:"notes"` Tags Tags `json:"tags"` DataFile string `json:"data_file"` LastBackupAt int64 `json:"last_backup_at"` MutexLock bool `json:"mutex_lock"` BaseStruct }
A ReminderData represents the whole reminder data-structure.
func BlankReminder ¶
func BlankReminder(askUserInput bool, dataFilePath string) (*ReminderData, error)
BlankReminder function creates blank ReminderData object.
func ReadDataFile ¶
func ReadDataFile(dataFilePath string, silentMode bool) (*ReminderData, error)
ReadDataFile function reads data file as instance of `ReminderData`
func (*ReminderData) AddNoteComment ¶
func (rd *ReminderData) AddNoteComment(note *Note, text string) error
AddNoteComment adds note's comment.
func (*ReminderData) AskTagIds ¶
func (rd *ReminderData) AskTagIds(tagIDs []int) []int
AskTagIds (recursive) ask tagIDs that are to be associated with a note.. It also registers tags for you, if user asks.
func (*ReminderData) AutoBackup ¶
func (rd *ReminderData) AutoBackup(gapSecs int64) (string, error)
AutoBackup does auto backup.
func (*ReminderData) CreateBackup ¶
func (rd *ReminderData) CreateBackup() (string, error)
CreateBackup creates timestamped backup. It returns path of the data file. Like utils.AskOptions, it prints any encountered error, but doesn't return the error.
func (*ReminderData) CreateDataFile ¶ added in v1.9.23
func (rd *ReminderData) CreateDataFile(msg string) error
CreateDataFile creates data file with current state of `rd`. The msg is any additional message to be printed.
func (*ReminderData) DisplayDataFile ¶
func (rd *ReminderData) DisplayDataFile() error
DisplayDataFile displays the data file. Like utils.AskOptions, it prints any encountered error, and returns that error just for information.
func (*ReminderData) FindNotesByTagId ¶
func (rd *ReminderData) FindNotesByTagId(tagID int, status NoteStatus) Notes
FindNotesByTagId gets all notes with given tagID and given status.
func (*ReminderData) FindNotesByTagSlug ¶
func (rd *ReminderData) FindNotesByTagSlug(tagSlug string, status NoteStatus) Notes
FindNotesByTagSlug gets all notes with given tagSlug and given status.
func (*ReminderData) GoogleCalendarEvents ¶ added in v1.9.16
func (rd *ReminderData) GoogleCalendarEvents(timezoneIANA string) ([]*gc.Event, error)
GoogleCalendarEvents returns list of Google Calendar Events.
func (*ReminderData) ListTags ¶
func (rd *ReminderData) ListTags() error
ListTags prompts a list of all tags (and their notes underneath). Like utils.AskOptions, it prints any encountered error, and returns that error just for information.
func (*ReminderData) NewNoteRegistration ¶
func (rd *ReminderData) NewNoteRegistration(tagIDs []int) (*Note, error)
NewNoteRegistration registers new note. The note is saved to the data file.
func (*ReminderData) NewTagRegistration ¶
func (rd *ReminderData) NewTagRegistration() (int, error)
NewTagRegistration registers a new tag.
func (*ReminderData) NotesApprachingDueDate ¶
func (rd *ReminderData) NotesApprachingDueDate(view string) Notes
NotesApprachingDueDate fetches all pending notes which are urgent. It accepts view as an argument with "default" or "long" as acceptable values Note: NotesApprachingDueDate is dangerous as it manipulates the due date (CompleteBy) date of repeating tags which can cause persitence of manupulated dates, if the returned data is persisted.
func (*ReminderData) PrintNoteAndAskOptions ¶
func (rd *ReminderData) PrintNoteAndAskOptions(note *Note) string
PrintNoteAndAskOptions prints note and display options. Like utils.AskOptions, it prints any encountered error, but doesn't returns that error just for information. It return string representing workflow direction.
func (*ReminderData) PrintNotesAndAskOptions ¶
func (rd *ReminderData) PrintNotesAndAskOptions(notes Notes, display_mode string, tagID int, sortBy string) error
PrintNotesAndAskOptions (recursively) prints notes interactively. In some cases, updated list notes will be fetched, so blank notes can be passed in those cases. Unless notes are to be fetched, the passed `status` doesn't make sense, so in such cases it can be passed as "fake". Like utils.AskOptions, it prints any encountered error, and returns that error just for information. It accepts following values for `display_mode`: - "done_notes": fetch only done notes - "suspended_notes": fetch only suspended notes - "pending_tag_notes": fetch pending notes with given tagID - "pending_only_main_notes": fetch pending notes with IsMain set as true - "pending_approaching_notes": fetch pending notes with approaching due date - "pending_long_view_notes": fetch long-view (52 weeks) of pending notes - "passed_notes": use passed notes
func (*ReminderData) RegisterBasicTags ¶
func (rd *ReminderData) RegisterBasicTags() error
RegisterBasicTags registers basic tags.
func (*ReminderData) SearchNotes ¶
func (rd *ReminderData) SearchNotes() error
SearchNotes searches throught all notes. Like utils.AskOptions, it prints any encountered error, and returns that error just for information.
func (*ReminderData) SortedTagSlugs ¶
func (rd *ReminderData) SortedTagSlugs() []string
SortedTagSlugs sorts the tags in-place and return slugs. Empty Tags is returned if there are no tags.
func (*ReminderData) Stats ¶
func (rd *ReminderData) Stats() (string, error)
Stats returns current status.
func (*ReminderData) SyncCalendar ¶ added in v1.9.16
func (rd *ReminderData) SyncCalendar(calOptions *calendar.Options) error
SyncCalendar syncs pending notes to Cloud Calendar.
func (*ReminderData) TagFromSlug ¶
func (rd *ReminderData) TagFromSlug(slug string) *Tag
TagFromSlug returns tag with given slug.
func (*ReminderData) TagIdsForGroup ¶
func (rd *ReminderData) TagIdsForGroup(group string) []int
TagIdsForGroup gets tag ids for given group.
func (*ReminderData) TagsFromIds ¶
func (rd *ReminderData) TagsFromIds(tagIDs []int) []string
TagsFromIds returns tag slugs from tagIDs.
func (*ReminderData) ToggleNoteMainFlag ¶
func (rd *ReminderData) ToggleNoteMainFlag(note *Note) error
ToggleNoteMainFlag toggles note's priority.
func (*ReminderData) UpdateDataFile ¶
func (rd *ReminderData) UpdateDataFile(msg string) error
UpdateDataFile updates data file with current state of `rd`. The msg is any additional message to be printed.
func (*ReminderData) UpdateNoteCompleteBy ¶
func (rd *ReminderData) UpdateNoteCompleteBy(note *Note, text string) error
UpdateNoteCompleteBy updates the note's due date (complete by).
func (*ReminderData) UpdateNoteStatus ¶
func (rd *ReminderData) UpdateNoteStatus(note *Note, status NoteStatus) error
UpdateNoteStatus updates note's status.
func (*ReminderData) UpdateNoteSummary ¶
func (rd *ReminderData) UpdateNoteSummary(note *Note, text string) error
UpdateNoteSummary updates the note's summary.
func (*ReminderData) UpdateNoteTags ¶
func (rd *ReminderData) UpdateNoteTags(note *Note, tagIDs []int) error
UpdateNoteTags updates note's tags.
func (*ReminderData) UpdateNoteText ¶
func (rd *ReminderData) UpdateNoteText(note *Note, text string) error
UpdateNoteText updates note's text.
type Tag ¶
type Tag struct { Id int `json:"id"` // internal int-based id of the tag Slug string `json:"slug"` // client-facing string-based id for tag Group string `json:"group"` // a note can be part of only one tag within a group BaseStruct }
A Tag represents classification of a note.
A note can have multiple tags, and a tag can be associated with multiple notes.
type Tagger ¶ added in v1.9.28
Tagger is interface representing ReminderData with TagsFromIds method.
type Tags ¶
type Tags []*Tag
A Tags is a slice of Tag objects.
By default it is sorted by its Slug field.
func BasicTags ¶
func BasicTags() Tags
BasicTags function returns an array of basic tags which can be used for initial setup of the application. Here some of the tags will have special meaning/functionality such as repeat-annually and repeat-monthly.
func (Tags) FromIds ¶
FromIds returns tags from tagIDs. It returns empty Tags if non of tagIDs match.
func (Tags) FromSlug ¶
FromSlug fetches tag with given slug. It return nil if given tag is not found.
func (Tags) IdsForGroup ¶
IdsForGroup returns tag ids of given group. It returns empty []int if group with given group name doesn't exist.