Skip to content

Commit

Permalink
feat(cli): lotus chain head --height to print epoch number
Browse files Browse the repository at this point in the history
A simpler version of what's currently possible with:

	lotus chain list --format '<height>' --count 1
  • Loading branch information
rvagg committed Oct 17, 2024
1 parent 50f72ed commit dfd9365
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cli/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ var ChainCmd = &cli.Command{
var ChainHeadCmd = &cli.Command{
Name: "head",
Usage: "Print chain head",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "height",
Usage: "print just the epoch number of the chain head",
},
},
Action: func(cctx *cli.Context) error {
afmt := NewAppFmt(cctx.App)

Expand All @@ -87,8 +93,12 @@ var ChainHeadCmd = &cli.Command{
return err
}

for _, c := range head.Cids() {
afmt.Println(c)
if cctx.Bool("height") {
afmt.Println(head.Height())
} else {
for _, c := range head.Cids() {
afmt.Println(c)
}
}
return nil
},
Expand Down

0 comments on commit dfd9365

Please sign in to comment.