From aed8e79cb022263529b8d583936b543d022940ed Mon Sep 17 00:00:00 2001 From: Dylan Ravel Date: Thu, 12 Feb 2026 09:54:03 -0800 Subject: [PATCH] gofmt and minor style/whitespace cleanups --- cmd/config/config.go | 6 +++--- cmd/entries/delete.go | 2 +- cmd/entries/manual.go | 9 ++++----- cmd/history/stats.go | 4 ++-- cmd/root.go | 4 ++-- cmd/tracking/pause.go | 2 +- cmd/tracking/start_test.go | 2 +- cmd/tracking/status.go | 2 +- cmd/tracking/stop.go | 2 +- cmd/utilities/version.go | 6 +++--- internal/currency/currency.go | 16 ++++++++-------- internal/export/csv.go | 2 +- internal/export/json.go | 2 +- internal/project/detect.go | 1 - internal/settings/config.go | 10 +++++----- internal/storage/db.go | 2 +- internal/storage/migrations_test.go | 2 +- internal/storage/models.go | 16 ++++++++-------- internal/ui/ui.go | 6 +++--- internal/update/checker.go | 6 +++--- 20 files changed, 50 insertions(+), 52 deletions(-) diff --git a/cmd/config/config.go b/cmd/config/config.go index 4ddfe9c..28d2b5e 100644 --- a/cmd/config/config.go +++ b/cmd/config/config.go @@ -13,10 +13,10 @@ import ( func ConfigCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "config", + Use: "config", Aliases: []string{"settings", "preferences"}, - Short: "Configure global tmpo settings", - Long: `Set up global configuration for tmpo including currency, date/time format, and timezone.`, + Short: "Configure global tmpo settings", + Long: `Set up global configuration for tmpo including currency, date/time format, and timezone.`, Run: func(cmd *cobra.Command, args []string) { ui.NewlineAbove() diff --git a/cmd/entries/delete.go b/cmd/entries/delete.go index 586cd96..eba687f 100644 --- a/cmd/entries/delete.go +++ b/cmd/entries/delete.go @@ -4,8 +4,8 @@ import ( "fmt" "os" - "github.com/DylanDevelops/tmpo/internal/settings" "github.com/DylanDevelops/tmpo/internal/project" + "github.com/DylanDevelops/tmpo/internal/settings" "github.com/DylanDevelops/tmpo/internal/storage" "github.com/DylanDevelops/tmpo/internal/ui" "github.com/manifoldco/promptui" diff --git a/cmd/entries/manual.go b/cmd/entries/manual.go index 54aa037..26ebbdc 100644 --- a/cmd/entries/manual.go +++ b/cmd/entries/manual.go @@ -62,7 +62,7 @@ func ManualCmd() *cobra.Command { } projectPrompt := promptui.Prompt{ - Label: projectLabel, + Label: projectLabel, AllowEdit: true, } @@ -290,7 +290,6 @@ func validateTime(input string) error { return fmt.Errorf("invalid time format, use 12-hour (e.g., 9:30 AM) or 24-hour (e.g., 14:30)") } - func validateEndDateTime(startDate, startTime, endDate, endTime, dateLayout string) error { start, err := parseDateTime(startDate, startTime, dateLayout) if err != nil { @@ -313,15 +312,15 @@ func parseDateTime(date, timeStr, dateLayout string) (time.Time, error) { normalizedTime := normalizeAMPM(timeStr) dateTime := fmt.Sprintf("%s %s", date, normalizedTime) - if dt, err := time.ParseInLocation(dateLayout + " 3:04 PM", dateTime, settings.GetDisplayTimezone()); err == nil { + if dt, err := time.ParseInLocation(dateLayout+" 3:04 PM", dateTime, settings.GetDisplayTimezone()); err == nil { return dt, nil } - if dt, err := time.ParseInLocation(dateLayout + " 03:04 PM", dateTime, settings.GetDisplayTimezone()); err == nil { + if dt, err := time.ParseInLocation(dateLayout+" 03:04 PM", dateTime, settings.GetDisplayTimezone()); err == nil { return dt, nil } - return time.ParseInLocation(dateLayout + " 15:04", dateTime, settings.GetDisplayTimezone()) + return time.ParseInLocation(dateLayout+" 15:04", dateTime, settings.GetDisplayTimezone()) } func normalizeAMPM(input string) string { diff --git a/cmd/history/stats.go b/cmd/history/stats.go index aefca0f..11cc646 100644 --- a/cmd/history/stats.go +++ b/cmd/history/stats.go @@ -6,8 +6,8 @@ import ( "sort" "time" - "github.com/DylanDevelops/tmpo/internal/settings" "github.com/DylanDevelops/tmpo/internal/currency" + "github.com/DylanDevelops/tmpo/internal/settings" "github.com/DylanDevelops/tmpo/internal/storage" "github.com/DylanDevelops/tmpo/internal/ui" "github.com/spf13/cobra" @@ -15,7 +15,7 @@ import ( var ( statsToday bool - statsWeek bool + statsWeek bool ) func StatsCmd() *cobra.Command { diff --git a/cmd/root.go b/cmd/root.go index ccadb31..e6c758f 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -46,12 +46,12 @@ Track time effortlessly with automatic project detection and simple commands.`, cmd.AddCommand(tracking.PauseCmd()) cmd.AddCommand(tracking.ResumeCmd()) cmd.AddCommand(tracking.StatusCmd()) - + // History cmd.AddCommand(history.LogCmd()) cmd.AddCommand(history.StatsCmd()) cmd.AddCommand(history.ExportCmd()) - + // Entries cmd.AddCommand(entries.EditCmd()) cmd.AddCommand(entries.DeleteCmd()) diff --git a/cmd/tracking/pause.go b/cmd/tracking/pause.go index fd57c4a..001a652 100644 --- a/cmd/tracking/pause.go +++ b/cmd/tracking/pause.go @@ -39,7 +39,7 @@ func PauseCmd() *cobra.Command { } err = db.StopEntry(running.ID) - if(err != nil) { + if err != nil { ui.PrintError(ui.EmojiError, fmt.Sprintf("%v", err)) os.Exit(1) } diff --git a/cmd/tracking/start_test.go b/cmd/tracking/start_test.go index bc9d32e..2900c2b 100644 --- a/cmd/tracking/start_test.go +++ b/cmd/tracking/start_test.go @@ -5,8 +5,8 @@ import ( "path/filepath" "testing" - "github.com/DylanDevelops/tmpo/internal/settings" "github.com/DylanDevelops/tmpo/internal/project" + "github.com/DylanDevelops/tmpo/internal/settings" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/cmd/tracking/status.go b/cmd/tracking/status.go index 73659fe..0ca7359 100644 --- a/cmd/tracking/status.go +++ b/cmd/tracking/status.go @@ -53,7 +53,7 @@ func StatusCmd() *cobra.Command { } if running.MilestoneName != nil && *running.MilestoneName != "" { - ui.PrintInfo(4, ui.Bold("Milestone"), *running.MilestoneName); + ui.PrintInfo(4, ui.Bold("Milestone"), *running.MilestoneName) } ui.NewlineBelow() diff --git a/cmd/tracking/stop.go b/cmd/tracking/stop.go index b6afaf6..d186fcd 100644 --- a/cmd/tracking/stop.go +++ b/cmd/tracking/stop.go @@ -38,7 +38,7 @@ func StopCmd() *cobra.Command { } err = db.StopEntry(running.ID) - if(err != nil) { + if err != nil { ui.PrintError(ui.EmojiError, fmt.Sprintf("%v", err)) os.Exit(1) } diff --git a/cmd/utilities/version.go b/cmd/utilities/version.go index 3c8920e..b60aba6 100644 --- a/cmd/utilities/version.go +++ b/cmd/utilities/version.go @@ -21,9 +21,9 @@ var releaseVersionRegex = regexp.MustCompile(`^v?\d+\.\d+\.\d+(-[\w.]+)?$`) func VersionCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "version", - Short: "Show version information", - Long: "Display the current version information including date and release URL.", + Use: "version", + Short: "Show version information", + Long: "Display the current version information including date and release URL.", Hidden: true, Run: func(cmd *cobra.Command, args []string) { DisplayVersionWithUpdateCheck() diff --git a/internal/currency/currency.go b/internal/currency/currency.go index ffa6c7c..1631f0f 100644 --- a/internal/currency/currency.go +++ b/internal/currency/currency.go @@ -16,14 +16,14 @@ var currencySymbols = map[string]string{ "ARS": "AR$", // Argentine Peso // Europe - "EUR": "€", // Euro - "GBP": "£", // British Pound Sterling - "CHF": "Fr", // Swiss Franc - "SEK": "kr", // Swedish Krona - "NOK": "kr", // Norwegian Krone - "DKK": "kr", // Danish Krone - "PLN": "zł", // Polish Zloty - "CZK": "Kč", // Czech Koruna + "EUR": "€", // Euro + "GBP": "£", // British Pound Sterling + "CHF": "Fr", // Swiss Franc + "SEK": "kr", // Swedish Krona + "NOK": "kr", // Norwegian Krone + "DKK": "kr", // Danish Krone + "PLN": "zł", // Polish Zloty + "CZK": "Kč", // Czech Koruna // Asia "JPY": "¥", // Japanese Yen diff --git a/internal/export/csv.go b/internal/export/csv.go index 338ca38..694b51d 100644 --- a/internal/export/csv.go +++ b/internal/export/csv.go @@ -53,4 +53,4 @@ func ToCSV(entries []*storage.TimeEntry, filename string) error { } return nil -} \ No newline at end of file +} diff --git a/internal/export/json.go b/internal/export/json.go index 14dd50b..cc208e5 100644 --- a/internal/export/json.go +++ b/internal/export/json.go @@ -54,4 +54,4 @@ func ToJson(entries []*storage.TimeEntry, filename string) error { } return nil -} \ No newline at end of file +} diff --git a/internal/project/detect.go b/internal/project/detect.go index 786cd4b..3c1a9a3 100644 --- a/internal/project/detect.go +++ b/internal/project/detect.go @@ -31,7 +31,6 @@ func DetectProject() (string, error) { return filepath.Base(cwd), nil } - func DetectConfiguredProject() (string, error) { return DetectConfiguredProjectWithOverride("") } diff --git a/internal/settings/config.go b/internal/settings/config.go index 2147e8c..4ba9353 100644 --- a/internal/settings/config.go +++ b/internal/settings/config.go @@ -10,10 +10,10 @@ import ( // IMPORTANT: When adding new fields to this struct, also update configTemplate below. type Config struct { - ProjectName string `yaml:"project_name"` - HourlyRate float64 `yaml:"hourly_rate,omitempty"` - Description string `yaml:"description,omitempty"` - ExportPath string `yaml:"export_path,omitempty"` + ProjectName string `yaml:"project_name"` + HourlyRate float64 `yaml:"hourly_rate,omitempty"` + Description string `yaml:"description,omitempty"` + ExportPath string `yaml:"export_path,omitempty"` } // IMPORTANT: When adding new fields to Config, update this template. @@ -63,7 +63,7 @@ func (c *Config) Save(path string) error { func Create(projectName string, hourlyRate float64) error { config := &Config{ ProjectName: projectName, - HourlyRate: hourlyRate, + HourlyRate: hourlyRate, } tmporc := filepath.Join(".", ".tmporc") diff --git a/internal/storage/db.go b/internal/storage/db.go index 8f18b76..2b20e28 100644 --- a/internal/storage/db.go +++ b/internal/storage/db.go @@ -306,7 +306,7 @@ func (d *Database) StopEntry(id int64) error { id, ) - if(err != nil) { + if err != nil { return fmt.Errorf("failed to stop entry: %w", err) } diff --git a/internal/storage/migrations_test.go b/internal/storage/migrations_test.go index f43a8f8..05fff1b 100644 --- a/internal/storage/migrations_test.go +++ b/internal/storage/migrations_test.go @@ -162,7 +162,7 @@ func TestMigrateTimestampsToUTC_LocalToUTC(t *testing.T) { assert.NoError(t, err) localTime := time.Date(2026, 1, 8, 15, 30, 0, 0, est) // 3:30 PM EST - expectedUTC := localTime.UTC() // Should convert to 8:30 PM UTC + expectedUTC := localTime.UTC() // Should convert to 8:30 PM UTC // Insert time entry with local timezone _, err = db.db.Exec( diff --git a/internal/storage/models.go b/internal/storage/models.go index f9e094d..00772f6 100644 --- a/internal/storage/models.go +++ b/internal/storage/models.go @@ -6,17 +6,17 @@ import ( ) type TimeEntry struct { - ID int64 - ProjectName string - StartTime time.Time - EndTime *time.Time - Description string - HourlyRate *float64 + ID int64 + ProjectName string + StartTime time.Time + EndTime *time.Time + Description string + HourlyRate *float64 MilestoneName *string } func (t *TimeEntry) Duration() time.Duration { - if( t.EndTime == nil) { + if t.EndTime == nil { return time.Since(t.StartTime) } @@ -50,4 +50,4 @@ func (m *Milestone) Duration() time.Duration { return time.Since(m.StartTime) } return m.EndTime.Sub(m.StartTime) -} \ No newline at end of file +} diff --git a/internal/ui/ui.go b/internal/ui/ui.go index f73d68f..e10b9d0 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -25,9 +25,9 @@ const ( FormatUnderline = "\033[4m" // Specific reset codes (don't reset colors) - ResetBoldDim = "\033[22m" // Reset bold and dim - ResetItalic = "\033[23m" // Reset italic - ResetUnderline = "\033[24m" // Reset underline + ResetBoldDim = "\033[22m" // Reset bold and dim + ResetItalic = "\033[23m" // Reset italic + ResetUnderline = "\033[24m" // Reset underline ) // Emoji Constants diff --git a/internal/update/checker.go b/internal/update/checker.go index f0a099c..2c92c46 100644 --- a/internal/update/checker.go +++ b/internal/update/checker.go @@ -10,9 +10,9 @@ import ( ) const ( - githubAPIURL = "https://api.github.com/repos/DylanDevelops/tmpo/releases/latest" - checkTimeout = 3 * time.Second - connectTimeout = 2 * time.Second + githubAPIURL = "https://api.github.com/repos/DylanDevelops/tmpo/releases/latest" + checkTimeout = 3 * time.Second + connectTimeout = 2 * time.Second ) type ReleaseInfo struct {