Skip to content

Commit

Permalink
Fix message for required flags
Browse files Browse the repository at this point in the history
  • Loading branch information
gandarez committed Jul 10, 2024
1 parent 8d8ecab commit e384f6d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
7 changes: 2 additions & 5 deletions cmd/logfile/logfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ import (
"github.com/spf13/viper"
)

const (
defaultFile = "wakatime.log"
defaultFolder = ".wakatime"
)
const defaultFile = "wakatime.log"

// Params contains log file parameters.
type Params struct {
Expand Down Expand Up @@ -60,7 +57,7 @@ func LoadParams(v *viper.Viper) (Params, error) {

folder, err := ini.WakaResourcesDir()
if err != nil {
return Params{}, fmt.Errorf("failed getting user's home directory: %s", err)
return Params{}, fmt.Errorf("failed getting resource directory: %s", err)

Check warning on line 60 in cmd/logfile/logfile.go

View check run for this annotation

Codecov / codecov/patch

cmd/logfile/logfile.go#L60

Added line #L60 was not covered by tests
}

params.File = filepath.Join(folder, defaultFile)
Expand Down
5 changes: 3 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func Run(cmd *cobra.Command, v *viper.Viper) {
log.Fatalf("failed to register custom lexers: %s", err)
}

shutdown := func() {}
shutdown := shutdownFn(func() {})

Check warning on line 78 in cmd/run.go

View check run for this annotation

Codecov / codecov/patch

cmd/run.go#L78

Added line #L78 was not covered by tests

// start profiling if enabled
if logFileParams.Metrics {
Expand Down Expand Up @@ -159,12 +159,13 @@ func Run(cmd *cobra.Command, v *viper.Viper) {
"--config-read",
"--config-write",
"--entity",
"--file-experts",

Check warning on line 162 in cmd/run.go

View check run for this annotation

Codecov / codecov/patch

cmd/run.go#L162

Added line #L162 was not covered by tests
"--offline-count",
"--print-offline-heartbeats",
"--sync-offline-activity",
"--today",
"--today-goal",
"--useragent",
"--user-agent",

Check warning on line 168 in cmd/run.go

View check run for this annotation

Codecov / codecov/patch

cmd/run.go#L168

Added line #L168 was not covered by tests
"--version",
}, ", "))

Expand Down
16 changes: 7 additions & 9 deletions pkg/ini/ini.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ type WakaHomeType int

const (
defaultFolder = ".wakatime"
// WakaHomeTypeUnknown is unknown WakaTime home type.
WakaHomeTypeUnknown WakaHomeType = iota
// WakaHomeTypeEnvVar is WakaTime home type from environment variable.
WakaHomeTypeEnvVar
// WakaHomeTypeOSDir is WakaTime home type from OS directory.
WakaHomeTypeOSDir
)

const (
// defaultFile is the name of the default wakatime config file.
defaultFile = ".wakatime.cfg"
// defaultInternalFile is the name of the default wakatime internal config file.
Expand All @@ -41,6 +32,13 @@ const (
DateFormat = time.RFC3339
// defaultTimeout is the default timeout for acquiring a lock.
defaultTimeout = time.Second * 5

// WakaHomeTypeUnknown is unknown WakaTime home type.
WakaHomeTypeUnknown WakaHomeType = iota
// WakaHomeTypeEnvVar is WakaTime home type from environment variable.
WakaHomeTypeEnvVar
// WakaHomeTypeOSDir is WakaTime home type from OS directory.
WakaHomeTypeOSDir
)

// Writer defines the methods to write to config file.
Expand Down
1 change: 1 addition & 0 deletions pkg/ini/ini_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestFilePath(t *testing.T) {
t.Run(name, func(t *testing.T) {
v := viper.New()
v.Set("config", test.ViperValue)

err := os.Setenv("WAKATIME_HOME", test.EnvVar)
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions pkg/offline/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
// dbLegacyFilename is the legacy bolt db filename.
const dbLegacyFilename = ".wakatime.bdb"

// QueueFilepathLegacy returns the legacy path for offline queue db file. If
// the waka's resource directory cannot be detected, it defaults to the
// QueueFilepathLegacy returns the path for offline queue db file. If
// the user's $HOME folder cannot be detected, it defaults to the
// current directory.
// This is used to support the old db file name and will be removed in the future.
func QueueFilepathLegacy() (string, error) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/offline/offline.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ func WithQueue(filepath string) heartbeat.HandleOption {
}

// QueueFilepath returns the path for offline queue db file. If
// the waka's resource directory cannot be detected, it defaults to the
// the resource directory cannot be detected, it defaults to the
// current directory.
func QueueFilepath() (string, error) {
folder, err := ini.WakaResourcesDir()
if err != nil {
return dbFilename, fmt.Errorf("failed getting waka's resource directory, defaulting to current directory: %s", err)
return dbFilename, fmt.Errorf("failed getting resource directory, defaulting to current directory: %s", err)

Check warning on line 95 in pkg/offline/offline.go

View check run for this annotation

Codecov / codecov/patch

pkg/offline/offline.go#L95

Added line #L95 was not covered by tests
}

return filepath.Join(folder, dbFilename), nil
Expand Down

0 comments on commit e384f6d

Please sign in to comment.