package control

import (
	commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
	"github.com/spf13/cobra"
)

var irCmd = &cobra.Command{
	Use:   "ir",
	Short: "Operations with inner ring nodes",
	Long:  "Operations with inner ring nodes",
}

func initControlIRCmd() {
	irCmd.AddCommand(tickEpochCmd)
	irCmd.AddCommand(removeNodeCmd)
	irCmd.AddCommand(irHealthCheckCmd)
	irCmd.AddCommand(removeContainerCmd)

	initControlIRTickEpochCmd()
	initControlIRRemoveNodeCmd()
	initControlIRHealthCheckCmd()
	initControlIRRemoveContainerCmd()
}

func printVUB(cmd *cobra.Command, vub uint32) {
	cmd.Printf("Transaction's valid until block is %d\n", vub)
}

func parseVUB(cmd *cobra.Command) uint32 {
	vub, err := cmd.Flags().GetUint32(irFlagNameVUB)
	commonCmd.ExitOnErr(cmd, "invalid valid until block value: %w", err)
	return vub
}