Skip to content

Commit a46558c

Browse files
committed
tsunami bin ... build, cobra, etc
1 parent 927be3f commit a46558c

5 files changed

Lines changed: 73 additions & 1 deletion

File tree

Taskfile.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,17 @@ tasks:
450450
desc: Run the tsunami frontend vite dev server
451451
cmd: npm run dev
452452
dir: tsunami/frontend
453+
454+
tsunami:build:
455+
desc: Build the tsunami binary.
456+
cmds:
457+
- cmd: "{{.RM}} bin/tsunami*"
458+
ignore_error: true
459+
- mkdir -p bin
460+
- cd tsunami && go build -ldflags "-X main.BuildTime=$({{.DATE}} +'%Y%m%d%H%M') -X main.TsunamiVersion={{.VERSION}}" -o ../bin/tsunami{{exeExt}} cmd/main-tsunami.go
461+
sources:
462+
- "tsunami/**/*.go"
463+
- "tsunami/go.mod"
464+
- "tsunami/go.sum"
465+
generates:
466+
- "bin/tsunami{{exeExt}}"

tsunami/cmd/main-tsunami.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os"
6+
7+
"github.com/spf13/cobra"
8+
"github.com/wavetermdev/waveterm/tsunami/tsunamibase"
9+
)
10+
11+
// these are set at build time
12+
var TsunamiVersion = "0.0.0"
13+
var BuildTime = "0"
14+
15+
var rootCmd = &cobra.Command{
16+
Use: "tsunami",
17+
Short: "Tsunami - A VDOM-based UI framework",
18+
Long: `Tsunami is a VDOM-based UI framework for building modern applications.`,
19+
}
20+
21+
var versionCmd = &cobra.Command{
22+
Use: "version",
23+
Short: "Print Tsunami version",
24+
Long: `Print Tsunami version`,
25+
Run: func(cmd *cobra.Command, args []string) {
26+
fmt.Println("v" + tsunamibase.TsunamiVersion)
27+
},
28+
}
29+
30+
func init() {
31+
rootCmd.AddCommand(versionCmd)
32+
}
33+
34+
func main() {
35+
tsunamibase.TsunamiVersion = TsunamiVersion
36+
if err := rootCmd.Execute(); err != nil {
37+
fmt.Println(err)
38+
os.Exit(1)
39+
}
40+
}

tsunami/go.mod

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ go 1.24.6
55
require (
66
github.com/google/uuid v1.6.0
77
github.com/gorilla/mux v1.8.1
8+
github.com/spf13/cobra v1.10.1
89
github.com/wavetermdev/htmltoken v0.2.0
910
)
1011

11-
require golang.org/x/net v0.43.0 // indirect
12+
require (
13+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
14+
github.com/spf13/pflag v1.0.9 // indirect
15+
golang.org/x/net v0.43.0 // indirect
16+
)

tsunami/go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
12
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
23
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
34
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
45
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
6+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
7+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
8+
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
9+
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
10+
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
11+
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
12+
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
513
github.com/wavetermdev/htmltoken v0.2.0 h1:sFVPPemlDv7/jg7n4Hx1AEF2m9MVAFjFpELWfhi/DlM=
614
github.com/wavetermdev/htmltoken v0.2.0/go.mod h1:5FM0XV6zNYiNza2iaTcFGj+hnMtgqumFHO31Z8euquk=
715
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
816
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
17+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
18+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

tsunami/tsunamibase/tsunamibase.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package tsunamibase
2+
3+
var TsunamiVersion = "0.0.0"

0 commit comments

Comments
 (0)