Files
gaze-indexer/cmd/cmd_version.go
waiemwor db5dc75c41 Feature/nodesale (#40)
* feat: recover nodesale module.

* fix: refactored.

* fix: fix table type.

* fix: add entity

* fix: bug UTC time.

* ci: try to tidy before testing

* ci: touch result file

* ci: use echo to create new file

* fix: try to skip test in ci

* fix: remove os.Exit

* fix: handle error

* feat: add todo note

* fix: Cannot run nodesale test because qtx is not initiated.

* fix: 50% chance public key compare incorrectly.

* fix: more consistent SQL

* fix: sanity refactor.

* fix: remove unused code.

* fix: move last_block_default to config file.

* fix: minor mistakes.

* fix:

* fix: refactor

* fix: refactor

* fix: delegate tx hash not record into db.

* refactor: prepare for moving integration tests.

* refactor: convert to unit tests.

* fix: change to using input values since output values deducted fee.

* feat: add extra unit test.

* fix: wrong timestamp format.

* fix: handle block timeout = 0

---------

Co-authored-by: Gaze <gazenw@users.noreply.github.com>
2024-08-05 11:33:20 +07:00

50 lines
1.2 KiB
Go

package cmd
import (
"fmt"
"github.com/cockroachdb/errors"
"github.com/gaze-network/indexer-network/common/errs"
"github.com/gaze-network/indexer-network/core/constants"
"github.com/gaze-network/indexer-network/modules/nodesale"
"github.com/gaze-network/indexer-network/modules/runes"
"github.com/spf13/cobra"
)
var versions = map[string]string{
"": constants.Version,
"runes": runes.Version,
"nodesale": nodesale.Version,
}
type versionCmdOptions struct {
Modules string
}
func NewVersionCommand() *cobra.Command {
opts := &versionCmdOptions{}
cmd := &cobra.Command{
Use: "version",
Short: "Show indexer-network version",
RunE: func(cmd *cobra.Command, args []string) error {
return versionHandler(opts, cmd, args)
},
}
flags := cmd.Flags()
flags.StringVar(&opts.Modules, "module", "", `Show version of a specific module. E.g. "runes"`)
return cmd
}
func versionHandler(opts *versionCmdOptions, _ *cobra.Command, _ []string) error {
version, ok := versions[opts.Modules]
if !ok {
// fmt.Fprintln(cmd.ErrOrStderr(), "Unknown module")
return errors.Wrap(errs.Unsupported, "Invalid module name")
}
fmt.Println(version)
return nil
}