Documentation
¶
Index ¶
- Variables
- func DetectProjectName() (string, error)
- func Execute()
- func GetChangelogUrl(version string) string
- func GetFormattedDate(inputDate string) string
- func GetVersionOutput() string
- func ShowAllTimeStats(entries []*storage.TimeEntry, db *storage.Database)
- func ShowPeriodStats(entries []*storage.TimeEntry, periodName string)
Constants ¶
This section is empty.
Variables ¶
var ( Version = "dev" Commit = "none" Date = "unknown" )
Functions ¶
func DetectProjectName ¶
DetectProjectName returns the name of the current project. It first attempts to load a configuration via config.FindAndLoad; if a configuration is found and its ProjectName field is non-empty, that value is returned. If no configuration or project name is available, DetectProjectName falls back to project.DetectProject() to determine the project name from the repository or environment. The function returns the determined project name and any error encountered during configuration loading or fallback detection.
func GetChangelogUrl ¶
func GetFormattedDate ¶
GetFormattedDate parses inputDate as an RFC3339 timestamp and returns the date formatted as "YYYY-MM-DD" wrapped in parentheses (for example "(2006-01-02)"). If inputDate is empty or cannot be parsed as RFC3339, it returns an empty string.
func GetVersionOutput ¶
func GetVersionOutput() string
GetVersionOutput returns the formatted version string used by both the version subcommand and the -v/--version flags
func ShowAllTimeStats ¶
ShowAllTimeStats prints aggregated all-time statistics to standard output. Given a slice of *storage.TimeEntry and a pointer to the database, the function:
- returns early with a message if entries is empty,
- computes and prints the total accumulated time and its hour equivalent,
- prints the total number of entries and number of tracked projects,
- aggregates time by project and prints a per-project line with duration and percentage of the total.
The function fetches the list of projects from the provided database to determine the number of projects tracked. Aggregation is done via a map[string]time.Duration; iteration order is therefore non-deterministic. If the total duration is zero, percentage values may be undefined. All output is produced using fmt.
func ShowPeriodStats ¶
ShowPeriodStats prints aggregated statistics for a named period to standard output. Given a slice of *storage.TimeEntry and a human-readable periodName, the function:
- returns early with a message if entries is empty,
- computes and prints the total accumulated time and its hour equivalent,
- prints the total number of entries,
- aggregates time by project and prints a per-project line with duration and percentage of the total,
- attempts to load configuration and, if a positive hourly rate is present, prints an estimated earnings line.
Aggregation is done via a map[string]time.Duration; iteration order is therefore non-deterministic. Percentages are computed as projectSeconds / totalSeconds * 100, so if the total duration is zero the percentage values may be undefined (NaN/Inf). All output is produced using fmt.
Types ¶
This section is empty.