Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
Expand All @@ -16,12 +15,11 @@ jobs:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- uses: actions/checkout@v6
- uses: actions/setup-go@v6
with:
go-version: 1.24
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v7
uses: golangci/golangci-lint-action@v9
with:
version: latest
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: go-setup
uses: actions/setup-go@v5
uses: actions/setup-go@v6
with:
go-version: 1.24
- name: install snapcraft
uses: samuelmeuli/action-snapcraft@v4
uses: samuelmeuli/action-snapcraft@v3
- name: install nix
uses: cachix/install-nix-action@v31
- name: goreleaser-setup
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/test-unit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@ name: Unit Tests
on:
pull_request:
push:
tags:
- v*
branches:
- main
jobs:
tests:
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
uses: actions/checkout@v6

- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version: 1.24

Expand All @@ -30,11 +34,11 @@ jobs:
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
files: ./coverage.txt
flags: unittests

- name: Report test coverage to DeepSource
uses: deepsourcelabs/test-coverage-action@v1
uses: deepsourcelabs/test-coverage-action@master
with:
key: go
coverage-file: ./coverage.txt
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- updated github workflows to use the newest versions of the actions
- removed unused code
- fixed assorted lint errors

### Thanks

Thank you to [@reva](https://github.com/reva) for the improvements on
[#292](https://github.com/lucassabreu/clockify-cli/pull/292).

## [v0.62.0] - 2026-03-20

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ deps-upgrade: ## upgrade go dependencies
go get -u -v $(MAIN_PKG)
go mod tidy

build: dist
build: clean dist

dist: deps-install dist/darwin dist/linux dist/windows ## build all cli versions (default)

Expand Down
10 changes: 7 additions & 3 deletions api/httpClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,19 @@ func (c *client) NewRequest(method, uri string, body interface{}) (*http.Request

// Do executes a http.Request inside the Clockify's Client
func (c *client) Do(
req *http.Request, v interface{}, name string) (*http.Response, error) {
req *http.Request, v interface{}, name string) (r *http.Response, err error) {

<-c.requestTickets

r, err := c.Client.Do(req)
r, err = c.Client.Do(req)
if err != nil {
return r, err
}
defer r.Body.Close()
defer func() {
if e := r.Body.Close(); e != nil {
err = e
}
}()

buf := new(bytes.Buffer)

Expand Down
10 changes: 5 additions & 5 deletions cmd/clockify-cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ func execute() int {

stderr := cmd.ErrOrStderr()
if errors.Is(err, terminal.InterruptErr) {
fmt.Fprintln(stderr)
_, _ = fmt.Fprintln(stderr)
return exitCancel
}

var flagError *cmdutil.FlagError
if errors.As(err, &flagError) {
fmt.Fprintln(stderr, flagError.Error())
fmt.Fprintln(stderr, cmd.UsageString())
_, _ = fmt.Fprintln(stderr, flagError.Error())
_, _ = fmt.Fprintln(stderr, cmd.UsageString())
return exitError
}

if f.Config().IsDebuging() {
fmt.Fprintf(stderr, "%+v\n", err)
_, _ = fmt.Fprintf(stderr, "%+v\n", err)
} else {
fmt.Fprintln(stderr, err.Error())
_, _ = fmt.Fprintln(stderr, err.Error())
}

return exitError
Expand Down
4 changes: 2 additions & 2 deletions internal/consoletest/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func RunTestConsole(
if err != nil {
t.Fatalf("failed to create console: %v", err)
}
defer c.Close()
defer func() { _ = c.Close() }()

finished := false
t.Cleanup(func() {
Expand All @@ -109,7 +109,7 @@ func RunTestConsole(
}()

go func() {
defer c.Tty().Close()
defer func() { _ = c.Tty().Close() }()
if err = setup(c.Tty(), c.Tty()); err != nil {
t.Error(err)
return
Expand Down
5 changes: 0 additions & 5 deletions pkg/cmd/client/add/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/lucassabreu/clockify-cli/api/dto"
"github.com/lucassabreu/clockify-cli/pkg/cmd/client/util"
"github.com/lucassabreu/clockify-cli/pkg/cmdutil"
"github.com/lucassabreu/clockify-cli/pkg/output/client"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -66,10 +65,6 @@ func NewCmdAdd(
return report(out, &of, cl)
}

if of.JSON {
client.ClientJSONPrint(cl, out)
}

return util.Report([]dto.Client{cl}, out, of)
},
}
Expand Down
6 changes: 4 additions & 2 deletions pkg/cmd/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ func NewCmdVersion(f cmdutil.Factory) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Shows the CLI version",
Run: func(cmd *cobra.Command, _ []string) {
RunE: func(cmd *cobra.Command, _ []string) error {
v := f.Version()
fmt.Fprintln(cmd.OutOrStdout(),
_, err := fmt.Fprintln(cmd.OutOrStdout(),
"Version: "+v.Tag+", Commit: "+v.Commit+", Build At: "+v.Date,
)

return err
},
}
}
4 changes: 3 additions & 1 deletion pkg/output/client/quiet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// ClientPrintQuietly will only print the IDs
func ClientPrintQuietly(cs []dto.Client, w io.Writer) error {
for i := 0; i < len(cs); i++ {
fmt.Fprintln(w, cs[i].ID)
if _, err := fmt.Fprintln(w, cs[i].ID); err != nil {
return err
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/output/project/quiet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// ProjectPrintQuietly will only print the IDs
func ProjectPrintQuietly(ps []dto.Project, w io.Writer) error {
for i := 0; i < len(ps); i++ {
fmt.Fprintln(w, ps[i].ID)
if _, err := fmt.Fprintln(w, ps[i].ID); err != nil {
return err
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/output/tag/quiet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// TagPrintQuietly will only print the IDs
func TagPrintQuietly(ts []dto.Tag, w io.Writer) error {
for i := 0; i < len(ts); i++ {
fmt.Fprintln(w, ts[i].ID)
if _, err := fmt.Fprintln(w, ts[i].ID); err != nil {
return err
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/output/task/quiet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// TaskPrintQuietly will only print the IDs
func TaskPrintQuietly(ts []dto.Task, w io.Writer) error {
for i := 0; i < len(ts); i++ {
fmt.Fprintln(w, ts[i].ID)
if _, err := fmt.Fprintln(w, ts[i].ID); err != nil {
return err
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/output/time-entry/quiet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// TimeEntriesPrintQuietly will only print the IDs
func TimeEntriesPrintQuietly(timeEntries []dto.TimeEntry, w io.Writer) error {
for i := 0; i < len(timeEntries); i++ {
fmt.Fprintln(w, timeEntries[i].ID)
if _, err := fmt.Fprintln(w, timeEntries[i].ID); err != nil {
return err
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/output/user/quiet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// UserPrintQuietly will only print the IDs
func UserPrintQuietly(users []dto.User, w io.Writer) error {
for i := 0; i < len(users); i++ {
fmt.Fprintln(w, users[i].ID)
if _, err := fmt.Fprintln(w, users[i].ID); err != nil {
return err
}
}

return nil
Expand Down
4 changes: 3 additions & 1 deletion pkg/output/workspace/quiet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import (
// WorkspacePrintQuietly will only print the IDs
func WorkspacePrintQuietly(ws []dto.Workspace, w io.Writer) error {
for i := 0; i < len(ws); i++ {
fmt.Fprintln(w, ws[i].ID)
if _, err := fmt.Fprintln(w, ws[i].ID); err != nil {
return err
}
}

return nil
Expand Down
Loading