Skip to content

Commit

Permalink
feat(tools): add upgrade info generator
Browse files Browse the repository at this point in the history
Signed-off-by: Artur Troian <troian.ap@gmail.com>
  • Loading branch information
troian committed Jul 27, 2023
1 parent 5073884 commit 4b75521
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tools/upgrade-info/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package main

import (
"context"
"fmt"
"log"
"os"

"github.com/spf13/cobra"

utilcli "github.com/akash-network/node/util/cli"
)

func main() {
cmd := cobra.Command{
Use: "upgrade-info",
Example: "upgrade-info <tag> <file>",
Args: cobra.RangeArgs(1, 2),
RunE: func(cmd *cobra.Command, args []string) error {
info, err := utilcli.UpgradeInfoFromTag(cmd.Context(), args[0], true)
if err != nil {
return err
}

if len(args) == 1 {
fmt.Printf("%s\n", info)
return nil
}

file, err := os.Create(args[1])
if err != nil {
return err
}
defer func() {
_ = file.Close()
}()

if _, err = file.WriteString(info); err != nil {
return err
}
return nil
},
}
if err := cmd.ExecuteContext(context.Background()); err != nil {
log.Fatal(err)
}
}

0 comments on commit 4b75521

Please sign in to comment.