mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
create cli command to print the version and the build commit and date
This commit is contained in:
@@ -34,6 +34,22 @@ const (
|
|||||||
modeCoord = "coord"
|
modeCoord = "coord"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Version represents the program based on the git tag
|
||||||
|
Version = "v0.1.0"
|
||||||
|
// Build represents the program based on the git commit
|
||||||
|
Build = "dev"
|
||||||
|
// Date represents the date of application was built
|
||||||
|
Date = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
func cmdVersion(c *cli.Context) error {
|
||||||
|
fmt.Printf("Version = \"%v\"\n", Version)
|
||||||
|
fmt.Printf("Build = \"%v\"\n", Build)
|
||||||
|
fmt.Printf("Date = \"%v\"\n", Date)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func cmdGenBJJ(c *cli.Context) error {
|
func cmdGenBJJ(c *cli.Context) error {
|
||||||
sk := babyjub.NewRandPrivKey()
|
sk := babyjub.NewRandPrivKey()
|
||||||
skBuf := [32]byte(sk)
|
skBuf := [32]byte(sk)
|
||||||
@@ -346,8 +362,8 @@ func getConfig(c *cli.Context) (*Config, error) {
|
|||||||
func main() {
|
func main() {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "hermez-node"
|
app.Name = "hermez-node"
|
||||||
app.Version = "0.1.0-alpha"
|
app.Version = Version
|
||||||
app.Flags = []cli.Flag{
|
flags := []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: flagMode,
|
Name: flagMode,
|
||||||
Usage: fmt.Sprintf("Set node `MODE` (can be \"%v\" or \"%v\")", modeSync, modeCoord),
|
Usage: fmt.Sprintf("Set node `MODE` (can be \"%v\" or \"%v\")", modeSync, modeCoord),
|
||||||
@@ -361,17 +377,23 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.Commands = []*cli.Command{
|
app.Commands = []*cli.Command{
|
||||||
|
{
|
||||||
|
Name: "version",
|
||||||
|
Aliases: []string{},
|
||||||
|
Usage: "Show the application version and build",
|
||||||
|
Action: cmdVersion,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "importkey",
|
Name: "importkey",
|
||||||
Aliases: []string{},
|
Aliases: []string{},
|
||||||
Usage: "Import ethereum private key",
|
Usage: "Import ethereum private key",
|
||||||
Action: cmdImportKey,
|
Action: cmdImportKey,
|
||||||
Flags: []cli.Flag{
|
Flags: append(flags,
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: flagSK,
|
Name: flagSK,
|
||||||
Usage: "ethereum `PRIVATE_KEY` in hex",
|
Usage: "ethereum `PRIVATE_KEY` in hex",
|
||||||
Required: true,
|
Required: true,
|
||||||
}},
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "genbjj",
|
Name: "genbjj",
|
||||||
@@ -385,30 +407,31 @@ func main() {
|
|||||||
Usage: "Wipe the SQL DB (HistoryDB and L2DB) and the StateDBs, " +
|
Usage: "Wipe the SQL DB (HistoryDB and L2DB) and the StateDBs, " +
|
||||||
"leaving the DB in a clean state",
|
"leaving the DB in a clean state",
|
||||||
Action: cmdWipeSQL,
|
Action: cmdWipeSQL,
|
||||||
Flags: []cli.Flag{
|
Flags: append(flags,
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: flagYes,
|
Name: flagYes,
|
||||||
Usage: "automatic yes to the prompt",
|
Usage: "automatic yes to the prompt",
|
||||||
Required: false,
|
Required: false,
|
||||||
}},
|
}),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "run",
|
Name: "run",
|
||||||
Aliases: []string{},
|
Aliases: []string{},
|
||||||
Usage: "Run the hermez-node in the indicated mode",
|
Usage: "Run the hermez-node in the indicated mode",
|
||||||
Action: cmdRun,
|
Action: cmdRun,
|
||||||
|
Flags: flags,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "discard",
|
Name: "discard",
|
||||||
Aliases: []string{},
|
Aliases: []string{},
|
||||||
Usage: "Discard blocks up to a specified block number",
|
Usage: "Discard blocks up to a specified block number",
|
||||||
Action: cmdDiscard,
|
Action: cmdDiscard,
|
||||||
Flags: []cli.Flag{
|
Flags: append(flags,
|
||||||
&cli.Int64Flag{
|
&cli.Int64Flag{
|
||||||
Name: flagBlock,
|
Name: flagBlock,
|
||||||
Usage: "last block number to keep",
|
Usage: "last block number to keep",
|
||||||
Required: false,
|
Required: false,
|
||||||
}},
|
}),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user