Skip to content

Commit

Permalink
new version
Browse files Browse the repository at this point in the history
  • Loading branch information
mvrpl committed May 26, 2024
1 parent ab46652 commit 07c1b8b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: goreleaser

on:
pull_request:
push:
tags:
- "*"

jobs:
goreleaser:
Expand Down
3 changes: 2 additions & 1 deletion generate_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type Data struct {
}

func GetData() []Data {
db, err := leveldb.OpenFile("speeds.db", nil)
home, _ := os.UserHomeDir()
db, err := leveldb.OpenFile(home+string(os.PathSeparator)+".speeds.db", nil)
if err != nil {
panic(err)
}
Expand Down
21 changes: 18 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ func mapSlice[T any, M any](a []T, f func(T) M) []M {
return n
}

const (
version = "1.5"
)

func RunSpeedTest() {
var speedtestClient = speedtest.New()

Expand Down Expand Up @@ -58,7 +62,9 @@ func RunSpeedTest() {
panic(err)
}

db, err := leveldb.OpenFile("speeds.db", nil)
home, _ := os.UserHomeDir()

db, err := leveldb.OpenFile(home+string(os.PathSeparator)+".speeds.db", nil)
if err != nil {
panic(err)
}
Expand All @@ -76,8 +82,10 @@ func RunSpeedTest() {
}

func main() {
app := cli.NewApp()
app.Name = "SpeedTest"
app := &cli.App{
Name: "SpeedTest",
Version: version,
}

app.Flags = []cli.Flag{
&cli.BoolFlag{
Expand All @@ -88,6 +96,11 @@ func main() {
Name: "report",
Value: false,
},
&cli.BoolFlag{
Name: "print-version",
Aliases: []string{"V"},
Usage: "print only the version",
},
&cli.TimestampFlag{
Name: "datetime",
Layout: "2006-01-02",
Expand All @@ -104,6 +117,8 @@ func main() {
RunSpeedTest()
} else if c.Bool("report") {
GenReport(*c.Timestamp("datetime"))
} else if c.Bool("print-version") {
fmt.Println(version)
} else {
panic(errors.New("need one flag"))
}
Expand Down

0 comments on commit 07c1b8b

Please sign in to comment.