mirror of https://github.com/status-im/go-waku.git
refactor: gowaku version
This commit is contained in:
parent
7e74155dca
commit
5243124af5
16
waku.go
16
waku.go
|
@ -8,6 +8,7 @@ import (
|
|||
"github.com/urfave/cli/v2"
|
||||
"github.com/waku-org/go-waku/waku"
|
||||
"github.com/waku-org/go-waku/waku/cliutils"
|
||||
"github.com/waku-org/go-waku/waku/v2/node"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
)
|
||||
|
||||
|
@ -187,12 +188,6 @@ func main() {
|
|||
Usage: "specifies where logging output should be written (stdout, file, file:./filename.log)",
|
||||
Destination: &options.LogOutput,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "version",
|
||||
Value: false,
|
||||
Usage: "prints the version",
|
||||
Destination: &options.Version,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "agent-string",
|
||||
Value: "go-waku",
|
||||
|
@ -455,8 +450,15 @@ func main() {
|
|||
rlnFlags := rlnFlags()
|
||||
cliFlags = append(cliFlags, rlnFlags...)
|
||||
|
||||
cli.VersionFlag = &cli.BoolFlag{
|
||||
Name: "version",
|
||||
Usage: "prints the version",
|
||||
}
|
||||
|
||||
app := &cli.App{
|
||||
Flags: cliFlags,
|
||||
Name: "gowaku",
|
||||
Version: node.GetVersionInfo().String(),
|
||||
Flags: cliFlags,
|
||||
Action: func(c *cli.Context) error {
|
||||
utils.InitLogger(options.LogEncoding, options.LogOutput)
|
||||
|
||||
|
|
|
@ -175,11 +175,6 @@ func Execute(options Options) {
|
|||
return
|
||||
}
|
||||
|
||||
if options.Version {
|
||||
fmt.Printf("version / git commit hash: %s-%s\n", node.Version, node.GitCommit)
|
||||
return
|
||||
}
|
||||
|
||||
if options.UseDB {
|
||||
if options.PersistPeers {
|
||||
// Create persistent peerstore
|
||||
|
|
|
@ -153,7 +153,6 @@ type Options struct {
|
|||
UseDB bool
|
||||
DBPath string
|
||||
AdvertiseAddress string
|
||||
Version bool // TODO: use vflag from urcli
|
||||
ShowAddresses bool
|
||||
LogLevel string
|
||||
LogEncoding string
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package node
|
||||
|
||||
// GitCommit is a commit hash.
|
||||
var GitCommit string
|
||||
|
||||
// Version is the version of go-waku at the time of compilation
|
||||
var Version string
|
|
@ -0,0 +1,32 @@
|
|||
package node
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
// GitCommit is a commit hash.
|
||||
var GitCommit string
|
||||
|
||||
// Version is the version of go-waku at the time of compilation
|
||||
var Version string
|
||||
|
||||
type VersionInfo struct {
|
||||
Version string
|
||||
Commit string
|
||||
System string
|
||||
Golang string
|
||||
}
|
||||
|
||||
func GetVersionInfo() VersionInfo {
|
||||
return VersionInfo{
|
||||
Version: Version,
|
||||
Commit: GitCommit,
|
||||
System: runtime.GOARCH + "/" + runtime.GOOS,
|
||||
Golang: runtime.Version(),
|
||||
}
|
||||
}
|
||||
|
||||
func (v VersionInfo) String() string {
|
||||
return fmt.Sprintf("%s-%s", v.Version, v.Commit)
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -48,6 +47,6 @@ func (d *DebugService) getV1Info(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
func (d *DebugService) getV1Version(w http.ResponseWriter, r *http.Request) {
|
||||
response := VersionResponse(fmt.Sprintf("%s-%s", node.Version, node.GitCommit))
|
||||
response := VersionResponse(node.GetVersionInfo().String())
|
||||
writeErrOrResponse(w, nil, response)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/waku-org/go-waku/waku/v2/node"
|
||||
|
@ -36,6 +35,6 @@ func (d *DebugService) GetV1Info(r *http.Request, args *InfoArgs, reply *InfoRep
|
|||
type VersionResponse string
|
||||
|
||||
func (d *DebugService) GetV1Version(r *http.Request, args *InfoArgs, reply *VersionResponse) error {
|
||||
*reply = VersionResponse(fmt.Sprintf("%s-%s", node.Version, node.GitCommit))
|
||||
*reply = VersionResponse(node.GetVersionInfo().String())
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue