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 6d56bf9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 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 waka's 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

0 comments on commit 6d56bf9

Please sign in to comment.