[#81] cmd/neofs-cli: Implement "epoch" sub-cmd of "netmap" cmd

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-11-05 10:15:28 +03:00 committed by Alex Vanin
parent 200fdbd361
commit 5d94594007

View file

@ -1,6 +1,7 @@
package cmd package cmd
import ( import (
"context"
"fmt" "fmt"
"github.com/spf13/cobra" "github.com/spf13/cobra"
@ -19,13 +20,28 @@ var netmapCmd = &cobra.Command{
func init() { func init() {
rootCmd.AddCommand(netmapCmd) rootCmd.AddCommand(netmapCmd)
// Here you will define your flags and configuration settings. netmapCmd.AddCommand(
getEpochCmd,
// Cobra supports Persistent Flags which will work for this command )
// and all subcommands, e.g.: }
// netmapCmd.PersistentFlags().String("foo", "", "A help for foo")
var getEpochCmd = &cobra.Command{
// Cobra supports local flags which will only run when this command Use: "epoch",
// is called directly, e.g.: Short: "Get current epoch number",
// netmapCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") 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
},
} }