Documentation ¶
Index ¶
- Constants
- Variables
- func CheckTags(tags []string) error
- func CompileKeyword(target string) (time.Time, error)
- func ContainsMoreThanOneBooleanFlag(flags ...bool) bool
- func EditFile(editor string, fpath string)
- func EnsureConfigDirExists(configDirectory string) error
- func FilterFramesByTimespan(start time.Time, end time.Time, frames *[]Frame, noCheck bool, tags []string) map[time.Time][]Frame
- func FormatCancelMessage(currentFrame CurrentFrame) string
- func FormatDateHeader(date time.Time) string
- func FormatEditFrameMessage(frame Frame) string
- func FormatFrameDelete(frame Frame) string
- func FormatFrameDescribe(frame Frame) string
- func FormatFrameLine(frame Frame) string
- func FormatNewFrameMessage(frame Frame) string
- func FormatNoFramesMessage() string
- func FormatNoNotesMessage() string
- func FormatNoProjectMessage() string
- func FormatNoteLine(note string) string
- func FormatNoteShowLine(index int, note string) string
- func FormatReportDuration(timeStart time.Time) string
- func FormatReportDurationDate(t time.Time) string
- func FormatReportProjectTagTotal(tag string, total time.Duration) string
- func FormatReportProjectTotal(project string, total time.Duration) string
- func FormatStartCurrentFrame(currentFrame CurrentFrame) string
- func FormatStartError(frame CurrentFrame) string
- func FormatStartFrame(frame Frame) string
- func FormatStatusFrameMessage(frame Frame) string
- func FormatStopFrameMessage(frame Frame) string
- func FormatTagNotValid() string
- func FormatTags(tags []string) string
- func FormatTimeStringNotValid() string
- func FramesEqual(f1 Frame, f2 Frame) bool
- func GetAppFilePath(fileName string, customConfDir string) string
- func GetCorrectConfigDirectory(customConfigPath string) string
- func GetEditorEnv() string
- func GetShortHex(sha string) string
- func GetTimeElapsed(dateStart, dateEnd time.Time) (int, int, int)
- func GetTimeElapsedForDuration(delta time.Duration) (int, int, int)
- func GetTimespanForMonth() (time.Time, time.Time)
- func GetTimespanForToday() (time.Time, time.Time)
- func GetTimespanForWeek() (time.Time, time.Time)
- func GetTimespanForYear() (time.Time, time.Time)
- func GetTimespanForYesterday() (time.Time, time.Time)
- func HasSameDate(t1 *time.Time, t2 *time.Time) bool
- func IsFrameInTimespan(frame Frame, start time.Time, end time.Time) bool
- func IsKeyword(target string) bool
- func IsTimeInTimespan(point time.Time, start time.Time, end time.Time) bool
- func IsTimespanNegative(start time.Time, end time.Time) bool
- func NormalizeDate(precise time.Time) time.Time
- func NormalizeTags(tags []string) []string
- func OrganizeFrameByTime(frames *[]Frame) map[time.Time][]Frame
- func PrettyDate(t *time.Time) string
- func RenderCurrentFrameStatus(currentFrame CurrentFrame, format string) string
- func RenderStatusFormatString(frame Frame, format string) string
- func SaveFrames(config ChronoConfig, frames Frames) error
- func SaveState(config ChronoConfig, state State) error
- func SortFramesByDate(frames []Frame)
- func SortTimeMapKeys(timemap *map[time.Time][]Frame) []time.Time
- func StringInSlice(target string, list []string) bool
- type ChronoConfig
- type CurrentFrame
- type Data
- type ErrFileDoesNotExist
- type ErrFrameNotFound
- type ErrFramesFileDoesNotExist
- type ErrStateFileDoesNotExist
- type Frame
- type FrameDeleteOptions
- type FrameFilterOptions
- type FrameGetOptions
- type FrameStorage
- type Frames
- func (s *Frames) Add(frame Frame)
- func (s *Frames) All() []Frame
- func (s *Frames) Delete(targetFrame Frame)
- func (s *Frames) Filter(filterOptions FrameFilterOptions) []Frame
- func (s *Frames) GetByIndex(index int) (Frame, bool)
- func (s *Frames) GetByUUID(id string) (Frame, bool)
- func (s *Frames) GetFrameIndex(target Frame) int
- func (s *Frames) Projects() []string
- func (s *Frames) Tags() []string
- func (s *Frames) Update(target Frame)
- type FramesRepo
- type GithubLatestRelease
- type JSONFramesRepo
- type JSONStateRepo
- type MsgpackFramesRepo
- type MsgpackStateRepo
- type SimpleFrame
- type State
- type StateRepo
- type StateStorage
- type TimespanFilterOptions
Constants ¶
const ChronoAppConf = "chrono"
ChronoAppConf is the name of the app's data directory
const ChronoConfDirEnvName = "CHRONO_CONFIG_DIR"
ChronoConfDirEnvName is name of the environment variable used to manually set the config directory
const ChronoConfigFilename = "config.toml"
ChronoConfigFilename is the config's expected filename
Variables ¶
var NoColor = false
NoColor if set to false will no color any output with ANSI color codes
Functions ¶
func CompileKeyword ¶ added in v1.1.0
CompileKeyword converts a given string containing a keyword into its associated time.Time
func ContainsMoreThanOneBooleanFlag ¶
ContainsMoreThanOneBooleanFlag is a helper method for checking if more than one boolean is true
func EnsureConfigDirExists ¶
EnsureConfigDirExists makes sure the configDirectory path exists
func FilterFramesByTimespan ¶
func FilterFramesByTimespan(start time.Time, end time.Time, frames *[]Frame, noCheck bool, tags []string) map[time.Time][]Frame
FilterFramesByTimespan returns only frames that are in the given timespan
func FormatCancelMessage ¶
func FormatCancelMessage(currentFrame CurrentFrame) string
FormatCancelMessage shows a message if the current state is stopped but not saved
func FormatDateHeader ¶
FormatDateHeader returns a time formated with Tuesday 2 January 2006
func FormatEditFrameMessage ¶
FormatEditFrameMessage returns the output when a frame is modified
func FormatFrameDelete ¶
FormatFrameDelete shows confirmation messasge to delete a frame
func FormatFrameDescribe ¶
FormatFrameDescribe shows information about a frame in a consise manner
func FormatFrameLine ¶
FormatFrameLine returns a frame line (all the metadata about a frame except for its notes)
func FormatNewFrameMessage ¶
FormatNewFrameMessage returns the output when a new frame is created
func FormatNoFramesMessage ¶
func FormatNoFramesMessage() string
FormatNoFramesMessage returns the output when there is no current frame
func FormatNoNotesMessage ¶
func FormatNoNotesMessage() string
FormatNoNotesMessage returns the output if there are no notes in the current frame
func FormatNoProjectMessage ¶
func FormatNoProjectMessage() string
FormatNoProjectMessage returns the output when there is no current frame
func FormatNoteLine ¶
FormatNoteLine formats a single frame note
func FormatNoteShowLine ¶
FormatNoteShowLine formats a single frame note for the notes show command
func FormatReportDuration ¶
FormatReportDuration returns the duration currently being viewed in the report command
func FormatReportDurationDate ¶
FormatReportDurationDate returns the date using format Mon 02 January 2006
func FormatReportProjectTagTotal ¶
FormatReportProjectTagTotal return the total time spent on a tag for a project
func FormatReportProjectTotal ¶
FormatReportProjectTotal returns the total time spent on a project
func FormatStartCurrentFrame ¶
func FormatStartCurrentFrame(currentFrame CurrentFrame) string
FormatStartCurrentFrame returns the output when a new frame is created
func FormatStartError ¶
func FormatStartError(frame CurrentFrame) string
FormatStartError returns a message formated red that says a project is already started
func FormatStartFrame ¶
FormatStartFrame returns the output when a new frame is created
func FormatStatusFrameMessage ¶
FormatStatusFrameMessage returns the output the current status for active frame
func FormatStopFrameMessage ¶
FormatStopFrameMessage returns the output when time tracking for a frame is stopped
func FormatTagNotValid ¶ added in v1.1.0
func FormatTagNotValid() string
FormatTagNotValid returns a message when a time string was unable to be parsed
func FormatTags ¶
FormatTags joins tags together and color them blue
func FormatTimeStringNotValid ¶
func FormatTimeStringNotValid() string
FormatTimeStringNotValid returns a message when a time string was unable to be parsed
func GetAppFilePath ¶
GetAppFilePath returns a file's path in the config directory through either an environment variable or the default path
func GetCorrectConfigDirectory ¶
GetCorrectConfigDirectory returns the correct config path where customConfigPath > Env Variable > Default value
func GetEditorEnv ¶
func GetEditorEnv() string
GetEditorEnv returns the preferred text editor's binary name
func GetShortHex ¶
GetShortHex returns the first six characters from a hex encoded SHA
func GetTimeElapsed ¶
GetTimeElapsed calculates the delta between two Times and returns the hours, minutes, and seconds for that delta
func GetTimeElapsedForDuration ¶
GetTimeElapsedForDuration returns the hours, minutes, seconds for a given duration
func GetTimespanForMonth ¶
GetTimespanForMonth returns the start and end date for the current month
func GetTimespanForToday ¶
GetTimespanForToday returns the the start date and end date of today
func GetTimespanForWeek ¶
GetTimespanForWeek returns the start and end date for the current week
func GetTimespanForYear ¶
GetTimespanForYear returns the start and end date for the current year
func GetTimespanForYesterday ¶ added in v1.1.0
GetTimespanForYesterday returns the start and end date for yesterday
func HasSameDate ¶
HasSameDate checks if the date (month, year, day) are the same
func IsFrameInTimespan ¶
IsFrameInTimespan checks if a frame's start and end time are both in the given timespan
func IsTimeInTimespan ¶
IsTimeInTimespan checks if point is inside the timespan between start and end
func IsTimespanNegative ¶
IsTimespanNegative returns true if a timespan has a negative amount of time, false otherwise
func NormalizeDate ¶
NormalizeDate strips hours, minutes, and seconds from a given time
func NormalizeTags ¶
NormalizeTags tags (trims the prefix, lowercases, and replaces spaces with dashes)
func OrganizeFrameByTime ¶
OrganizeFrameByTime returns a map of frames where the key is the date of the frame
func PrettyDate ¶
PrettyDate returns the date using format 2 January 2006 15:04
func RenderCurrentFrameStatus ¶
func RenderCurrentFrameStatus(currentFrame CurrentFrame, format string) string
RenderCurrentFrameStatus returns the status output using Go template string
func RenderStatusFormatString ¶
RenderStatusFormatString returns the status output using Go template string
func SaveFrames ¶
func SaveFrames(config ChronoConfig, frames Frames) error
SaveFrames writes frames
func SaveState ¶
func SaveState(config ChronoConfig, state State) error
SaveState writes the state to the file
func SortFramesByDate ¶
func SortFramesByDate(frames []Frame)
SortFramesByDate sorts frame by its start date
func SortTimeMapKeys ¶
SortTimeMapKeys sorts a timemap by its key (a time.Time)
func StringInSlice ¶
StringInSlice checks if a string is present in a slice
Types ¶
type ChronoConfig ¶
ChronoConfig contains the currently used config dir path as well as any configuration options stored in config.toml
func GetConfig ¶
func GetConfig(configDirectory string) ChronoConfig
GetConfig loads the a confi file if it exists and returns a ChronoConfig struct
type CurrentFrame ¶
type CurrentFrame struct { Project string StartedAt time.Time UpdatedAt time.Time Tags []string Notes []string }
CurrentFrame contains data for the current frame
type ErrFileDoesNotExist ¶
type ErrFileDoesNotExist struct {
// contains filtered or unexported fields
}
ErrFileDoesNotExist represents when a file doesn't exist on the file system
func NewErrFileDoesNotExist ¶
func NewErrFileDoesNotExist(message string) *ErrFileDoesNotExist
NewErrFileDoesNotExist creates a new ErrFileDoesNotExist
func (*ErrFileDoesNotExist) Error ¶
func (e *ErrFileDoesNotExist) Error() string
Error returns the error message
type ErrFrameNotFound ¶
type ErrFrameNotFound struct {
// contains filtered or unexported fields
}
ErrFrameNotFound means a frame wasn't found
func NewErrFrameNotFound ¶
func NewErrFrameNotFound(message string) *ErrFrameNotFound
NewErrFrameNotFound creates a new ErrFrameNotFound
func (*ErrFrameNotFound) Error ¶
func (e *ErrFrameNotFound) Error() string
Error returns the error message
type ErrFramesFileDoesNotExist ¶
type ErrFramesFileDoesNotExist struct {
// contains filtered or unexported fields
}
ErrFramesFileDoesNotExist represents when a file doesn't exist on the file system
func NewErrFramesFileDoesNotExist ¶
func NewErrFramesFileDoesNotExist(message string) *ErrFramesFileDoesNotExist
NewErrFramesFileDoesNotExist creates a new ErrFileDoesNotExist
func (*ErrFramesFileDoesNotExist) Error ¶
func (e *ErrFramesFileDoesNotExist) Error() string
Error returns the error message
type ErrStateFileDoesNotExist ¶
type ErrStateFileDoesNotExist struct {
// contains filtered or unexported fields
}
ErrStateFileDoesNotExist represents when a file doesn't exist on the file system
func (*ErrStateFileDoesNotExist) Error ¶
func (e *ErrStateFileDoesNotExist) Error() string
Error returns the error message
type Frame ¶
type Frame struct { UUID string Project string StartedAt time.Time EndedAt time.Time UpdatedAt time.Time Tags []string Notes []string }
Frame is a timespan containing some metadata
func ConvertSimpleFrameToFrame ¶
func ConvertSimpleFrameToFrame(uuid string, rawFrame SimpleFrame) (Frame, error)
ConvertSimpleFrameToFrame converts a raw frame back to a frame
func FilterFrames ¶
func FilterFrames(frames *[]Frame, filterOptions FrameFilterOptions) []Frame
FilterFrames filters out a list of frames based on the given FrameFilterOptions
type FrameDeleteOptions ¶
type FrameDeleteOptions struct {
Target string
}
FrameDeleteOptions contains data needed to remove a frame
type FrameFilterOptions ¶
type FrameFilterOptions struct { TimespanFilter TimespanFilterOptions Tags []string Projects []string }
FrameFilterOptions contains filtering data for retrieving frames. An empty object means no filtering
type FrameGetOptions ¶
type FrameGetOptions struct {
Target string
}
FrameGetOptions contains filtering information needed to find a single Frame
type FrameStorage ¶
type FrameStorage interface { All(filterOptions FrameFilterOptions) ([]Frame, error) Add(frame Frame) (Frame, error) Get(getOptions FrameGetOptions) (Frame, error) Delete(deleteOptions FrameDeleteOptions) (Frame, error) Update(frame Frame) (Frame, error) Projects() ([]string, error) Tags() ([]string, error) }
FrameStorage is an interface for a frame storage backend
type Frames ¶
type Frames struct {
Frames []Frame
}
Frames contains recordered frames
func (*Frames) Filter ¶
func (s *Frames) Filter(filterOptions FrameFilterOptions) []Frame
Filter retrieves frames based on filter options
func (*Frames) GetByIndex ¶
GetByIndex retrieves a frame by its index
func (*Frames) GetFrameIndex ¶ added in v1.1.0
type FramesRepo ¶
FramesRepo is an interface for loading/saving frames
type GithubLatestRelease ¶
type GithubLatestRelease struct { URL string `json:"url"` HTMLURL string `json:"html_url"` AssetsURL string `json:"assets_url"` UploadURL string `json:"upload_url"` TarballURL string `json:"tarball_url"` ZipballURL string `json:"zipball_url"` ID int `json:"id"` NodeID string `json:"node_id"` TagName string `json:"tag_name"` TargetCommitish string `json:"target_commitish"` Name string `json:"name"` Body string `json:"body"` Draft bool `json:"draft"` Prerelease bool `json:"prerelease"` CreatedAt time.Time `json:"created_at"` PublishedAt time.Time `json:"published_at"` Author struct { Login string `json:"login"` ID int `json:"id"` NodeID string `json:"node_id"` AvatarURL string `json:"avatar_url"` GravatarID string `json:"gravatar_id"` URL string `json:"url"` HTMLURL string `json:"html_url"` FollowersURL string `json:"followers_url"` FollowingURL string `json:"following_url"` GistsURL string `json:"gists_url"` StarredURL string `json:"starred_url"` SubscriptionsURL string `json:"subscriptions_url"` OrganizationsURL string `json:"organizations_url"` ReposURL string `json:"repos_url"` EventsURL string `json:"events_url"` ReceivedEventsURL string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` } `json:"author"` Assets []struct { URL string `json:"url"` BrowserDownloadURL string `json:"browser_download_url"` ID int `json:"id"` NodeID string `json:"node_id"` Name string `json:"name"` Label string `json:"label"` State string `json:"state"` ContentType string `json:"content_type"` Size int `json:"size"` DownloadCount int `json:"download_count"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` Uploader struct { Login string `json:"login"` ID int `json:"id"` NodeID string `json:"node_id"` AvatarURL string `json:"avatar_url"` GravatarID string `json:"gravatar_id"` URL string `json:"url"` HTMLURL string `json:"html_url"` FollowersURL string `json:"followers_url"` FollowingURL string `json:"following_url"` GistsURL string `json:"gists_url"` StarredURL string `json:"starred_url"` SubscriptionsURL string `json:"subscriptions_url"` OrganizationsURL string `json:"organizations_url"` ReposURL string `json:"repos_url"` EventsURL string `json:"events_url"` ReceivedEventsURL string `json:"received_events_url"` Type string `json:"type"` SiteAdmin bool `json:"site_admin"` } `json:"uploader"` } `json:"assets"` }
GithubLatestRelease represents the data returned from the releases/latest endpoint. Autogenerated
type JSONFramesRepo ¶
type JSONFramesRepo struct {
// contains filtered or unexported fields
}
JSONFramesRepo stores state in the JSON format
func (JSONFramesRepo) Load ¶
func (s JSONFramesRepo) Load() (Frames, error)
Load frames stored in the JSON format
func (JSONFramesRepo) Save ¶
func (s JSONFramesRepo) Save(f *Frames) error
Save writes frames using the JSON format
type JSONStateRepo ¶
type JSONStateRepo struct {
// contains filtered or unexported fields
}
JSONStateRepo retrieves state in msgpack format
func (JSONStateRepo) Save ¶
func (s JSONStateRepo) Save(state State) error
Save writes the state to the current file
type MsgpackFramesRepo ¶
type MsgpackFramesRepo struct {
// contains filtered or unexported fields
}
MsgpackFramesRepo retrieves state in msgpack format
func (MsgpackFramesRepo) Load ¶
func (s MsgpackFramesRepo) Load() (Frames, error)
Load retrieves frames from the msgpack format
func (MsgpackFramesRepo) Save ¶
func (s MsgpackFramesRepo) Save(f *Frames) error
Save writes frames using the msgpack format
type MsgpackStateRepo ¶
type MsgpackStateRepo struct {
// contains filtered or unexported fields
}
MsgpackStateRepo retrieves state in msgpack format
func (MsgpackStateRepo) Save ¶
func (s MsgpackStateRepo) Save(state State) error
Save writes the state to the current file
type SimpleFrame ¶
type SimpleFrame struct { Project string StartedAt string EndedAt string Tags []string Notes []string }
SimpleFrame is used for converting to and from JSON
func ConvertFrameToSimpleFrame ¶
func ConvertFrameToSimpleFrame(frame Frame) SimpleFrame
ConvertFrameToSimpleFrame converts a frame to a raw frame
type State ¶
type State struct {
CurrentFrame CurrentFrame
}
State contains the CurrentFrame and provides methods for interacting with it
func (*State) Get ¶
func (s *State) Get() CurrentFrame
Get retreives the CurrentFrame from the State