From 5d94594007cadc993981dd194d3c06167b338b9d Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Thu, 5 Nov 2020 10:15:28 +0300 Subject: [PATCH] [#81] cmd/neofs-cli: Implement "epoch" sub-cmd of "netmap" cmd Signed-off-by: Leonard Lyubich --- cmd/neofs-cli/modules/netmap.go | 34 ++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/cmd/neofs-cli/modules/netmap.go b/cmd/neofs-cli/modules/netmap.go index fbb09cd91..38ca44fff 100644 --- a/cmd/neofs-cli/modules/netmap.go +++ b/cmd/neofs-cli/modules/netmap.go @@ -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 + }, }