forked from TrueCloudLab/frostfs-node
[#81] cmd/neofs-cli: Implement "epoch" sub-cmd of "netmap" cmd
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
200fdbd361
commit
5d94594007
1 changed files with 25 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -19,13 +20,28 @@ var netmapCmd = &cobra.Command{
|
|||
func init() {
|
||||
rootCmd.AddCommand(netmapCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// netmapCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// netmapCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
netmapCmd.AddCommand(
|
||||
getEpochCmd,
|
||||
)
|
||||
}
|
||||
|
||||
var getEpochCmd = &cobra.Command{
|
||||
Use: "epoch",
|
||||
Short: "Get current epoch number",
|
||||
Long: "Get current epoch number",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
cli, err := getSDKClient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
e, err := cli.Epoch(context.Background())
|
||||
if err != nil {
|
||||
return fmt.Errorf("rpc error: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println(e)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue