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
3 changes: 2 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ before:
- go mod tidy

builds:
- binary: loops
- main: ./cmd/loops
binary: loops
env:
- CGO_ENABLED=0
goos:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ To install a specific version or to a custom path, append `-s -- <version> <path
irm https://raw.githubusercontent.com/Loops-so/cli/main/install.ps1 | iex
```

### Go install

```bash
go install github.com/loops-so/cli/cmd/loops@latest
```

## Auth

The CLI requires a Loops API key. Get one from [Settings > API](https://app.loops.so/settings?page=api).
Expand Down
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tasks:
deps:
- deps
cmds:
- go build -o dist/loops
- go build -o dist/loops ./cmd/loops

test:
desc: run tests
Expand Down
3 changes: 0 additions & 3 deletions main.go → cmd/loops/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/*
Copyright © 2026 Loops <support@loops.so>
*/
package main

import "github.com/loops-so/cli/cmd"
Expand Down
22 changes: 22 additions & 0 deletions cmd/update_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ func upgradeCommand() string {
if isHomebrew() {
return "brew upgrade loops"
}
if isGoInstall() {
return "go install github.com/loops-so/cli/cmd/loops@latest"
}
installDir := binDir()
if runtime.GOOS == "windows" {
if installDir != "" {
Expand All @@ -147,6 +150,25 @@ func binDir() string {
return filepath.Dir(exe)
}

func isGoInstall() bool {
dir := binDir()
if dir == "" {
return false
}
if gobin := os.Getenv("GOBIN"); gobin != "" && dir == gobin {
return true
}
gopath := os.Getenv("GOPATH")
if gopath == "" {
home, err := os.UserHomeDir()
if err != nil {
return false
}
gopath = filepath.Join(home, "go")
}
return dir == filepath.Join(gopath, "bin")
}

func isHomebrew() bool {
exe, err := os.Executable()
if err != nil {
Expand Down
13 changes: 13 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cmd
import (
"fmt"
"io"
"runtime/debug"
"strings"

"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -32,5 +34,16 @@ func runVersion(w io.Writer) error {
}

func init() {
if info, ok := debug.ReadBuildInfo(); ok && version == "dev" {
if info.Main.Version != "" && info.Main.Version != "(devel)" {
version = strings.TrimPrefix(info.Main.Version, "v")
}
for _, s := range info.Settings {
if s.Key == "vcs.revision" && len(s.Value) >= 7 {
commit = s.Value[:7]
break
}
}
}
rootCmd.AddCommand(versionCmd)
}