Skip to content

Commit

Permalink
Merge pull request #1036 from wakatime/misc/guess-language-doc
Browse files Browse the repository at this point in the history
Add guess-language to USAGE doc
  • Loading branch information
gandarez authored Mar 19, 2024
2 parents fcfd890 + c3ed652 commit bad54b4
Show file tree
Hide file tree
Showing 28 changed files with 111 additions and 80 deletions.
2 changes: 2 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ hostname = machinename
log_file =
import_cfg = /path/to/another/wakatime.cfg
metrics = true
guess_language = true

[projectmap]
projects/foo = new project name
Expand Down Expand Up @@ -110,6 +111,7 @@ some/submodule/name = new project name
| log_file | Optional log file path. | _filepath_ | `~/.wakatime/wakatime.log` |
| import_cfg | Optional path to another wakatime.cfg file to import. If set it will overwrite values loaded from $WAKATIME_HOME/.wakatime.cfg file. | _filepath_ | |
| metrics | When set, collects metrics usage in '~/.wakatime/metrics' folder. For further reference visit <https://go.dev/blog/pprof>. | _bool_ | `false` |
| guess_language | When `true`, enables detecting programming language from file contents. | _bool_ | `false` |

### Project Map Section

Expand Down
9 changes: 6 additions & 3 deletions cmd/fileexperts/fileexperts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ func TestFileExperts_ErrApi(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -172,8 +173,9 @@ func TestFileExperts_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -205,8 +207,9 @@ func TestFileExperts_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
13 changes: 5 additions & 8 deletions cmd/heartbeat/heartbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func TestSendHeartbeats_WithFiltering_Exclude(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)

numCalls++
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestSendHeartbeats_ExtraHeartbeats_Sanitize(t *testing.T) {
numCalls int
)

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
// send response
w.WriteHeader(http.StatusCreated)

Expand Down Expand Up @@ -724,10 +724,9 @@ func TestSendHeartbeats_ErrAuth_UnsetAPIKey(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusCreated)
})

Expand Down Expand Up @@ -760,10 +759,9 @@ func TestSendHeartbeats_ErrBackoff(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -824,10 +822,9 @@ func TestSendHeartbeats_ErrBackoff_Verbose(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

// send response
w.WriteHeader(http.StatusInternalServerError)
})

Expand Down
2 changes: 1 addition & 1 deletion cmd/params/params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1812,8 +1812,8 @@ func TestLoad_API_APIKeyInvalid(t *testing.T) {
require.Error(t, err)

var errauth api.ErrAuth
assert.ErrorAs(t, err, &errauth)

assert.ErrorAs(t, err, &errauth)
assert.EqualError(t, errauth, "invalid api key format")
})
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func NewRootCMD() *cobra.Command {
cmd := &cobra.Command{
Use: "wakatime-cli",
Short: "Command line interface used by all WakaTime text editor plugins.",
Run: func(cmd *cobra.Command, args []string) {
Run: func(cmd *cobra.Command, _ []string) {
Run(cmd, v)
},
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/run_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
func TestRunCmd(t *testing.T) {
v := viper.New()

ret := runCmd(v, false, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, false, false, func(_ *viper.Viper) (int, error) {
return exitcode.Success, nil
})

Expand All @@ -35,7 +35,7 @@ func TestRunCmd(t *testing.T) {
func TestRunCmd_Err(t *testing.T) {
v := viper.New()

ret := runCmd(v, false, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, false, false, func(_ *viper.Viper) (int, error) {
return exitcode.ErrGeneric, errors.New("fail")
})

Expand Down Expand Up @@ -95,7 +95,7 @@ func TestRunCmd_ErrOfflineEnqueue(t *testing.T) {
v.Set("key", "00000000-0000-4000-8000-000000000000")
v.Set("plugin", "vim")

ret := runCmd(v, true, false, func(v *viper.Viper) (int, error) {
ret := runCmd(v, true, false, func(_ *viper.Viper) (int, error) {
return exitcode.ErrGeneric, errors.New("fail")
})

Expand Down
18 changes: 9 additions & 9 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestRunCmd_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand All @@ -76,7 +76,7 @@ func TestRunCmd_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -125,7 +125,7 @@ func TestRunCmd_Verbose_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand All @@ -149,7 +149,7 @@ func TestRunCmd_Verbose_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -198,7 +198,7 @@ func TestRunCmd_SendDiagnostics_Err(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, errors.New("fail")
}
Expand Down Expand Up @@ -307,7 +307,7 @@ func TestRunCmd_SendDiagnostics_Panic(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++

panic("fail")
Expand Down Expand Up @@ -418,7 +418,7 @@ func TestRunCmd_SendDiagnostics_NoLogs_Panic(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++

panic("fail")
Expand Down Expand Up @@ -527,7 +527,7 @@ func TestRunCmd_SendDiagnostics_WakaError(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 42, offline.ErrOpenDB{Err: errors.New("fail")}
}
Expand Down Expand Up @@ -630,7 +630,7 @@ func TestRunCmdWithOfflineSync(t *testing.T) {

var cmdNumCalls int

cmdFn := func(v *viper.Viper) (int, error) {
cmdFn := func(_ *viper.Viper) (int, error) {
cmdNumCalls++
return 0, nil
}
Expand Down
9 changes: 6 additions & 3 deletions cmd/today/today_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ func TestToday_ErrApi(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -104,8 +105,9 @@ func TestToday_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -137,8 +139,9 @@ func TestToday_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/statusbar/today", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
9 changes: 6 additions & 3 deletions cmd/todaygoal/todaygoal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ func TestGoal_ErrApi(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand Down Expand Up @@ -111,8 +112,9 @@ func TestGoal_ErrAuth(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand Down Expand Up @@ -146,8 +148,9 @@ func TestGoal_ErrBadRequest(t *testing.T) {
var numCalls int

router.HandleFunc(
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, req *http.Request) {
"/users/current/goals/00000000-0000-4000-8000-000000000000", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
go.etcd.io/bbolt v1.3.7 h1:j+zJOnnEjF/kyHlDDgGnVL/AIqIJPq8UoB2GSNfkUfQ=
go.etcd.io/bbolt v1.3.7/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.etcd.io/bbolt v1.3.8 h1:xs88BrvEv273UsB79e0hcVrlUWmS0a8upikMFhSyAtA=
go.etcd.io/bbolt v1.3.8/go.mod h1:N9Mkw9X8x5fupy0IKsmuqVtoGDyxsaDlbk4Rd05IAQw=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
Expand Down Expand Up @@ -433,8 +431,6 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
8 changes: 4 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func TestSendHeartbeats_ErrAuth_InvalidAPIKEY(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(_ http.ResponseWriter, _ *http.Request) {
numCalls++
})

Expand Down Expand Up @@ -702,7 +702,7 @@ func TestOfflineCount(t *testing.T) {
apiURL, router, close := setupTestServer()
defer close()

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
_, err := io.Copy(w, strings.NewReader("500 error test"))
require.NoError(t, err)
Expand Down Expand Up @@ -781,7 +781,7 @@ func TestPrintOfflineHeartbeats(t *testing.T) {
apiURL, router, close := setupTestServer()
defer close()

router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/heartbeats.bulk", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
_, err := io.Copy(w, strings.NewReader("500 error test"))
require.NoError(t, err)
Expand Down Expand Up @@ -1021,7 +1021,7 @@ func setupTestServer() (string, *http.ServeMux, func()) {
router := http.NewServeMux()
srv := httptest.NewServer(router)

router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/plugins/errors", func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusCreated)
})

Expand Down
9 changes: 6 additions & 3 deletions pkg/api/fileexperts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ func TestClient_FileExperts_Err(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusInternalServerError)
})

Expand All @@ -152,8 +153,9 @@ func TestClient_FileExperts_ErrAuth(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusUnauthorized)
})

Expand All @@ -180,8 +182,9 @@ func TestClient_FileExperts_ErrBadRequest(t *testing.T) {

var numCalls int

router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, req *http.Request) {
router.HandleFunc("/users/current/file_experts", func(w http.ResponseWriter, _ *http.Request) {
numCalls++

w.WriteHeader(http.StatusBadRequest)
})

Expand Down
Loading

0 comments on commit bad54b4

Please sign in to comment.