policy-reader/modules/chains/root.go
Denis Kirillov c40ad3627d Add listing user/container chains by name
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2024-08-29 09:42:39 +03:00

38 lines
1 KiB
Go

package chains
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var Cmd = &cobra.Command{
Use: "chains",
Short: "Chain related policy operations",
Long: "Chain related policy operations",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
if viper.IsSet(rpcEndpointFlag) {
return cmd.Parent().PersistentFlags().Set(rpcEndpointFlag, viper.GetString(rpcEndpointFlag))
}
return nil
},
}
const (
rpcEndpointFlag = "rpc-endpoint"
policyHashFlag = "policy-hash"
frostfsidHashFlag = "frostfsid-hash"
)
func init() {
Cmd.PersistentFlags().StringP(rpcEndpointFlag, "r", "", "Neo-go endpoint")
Cmd.PersistentFlags().String(policyHashFlag, "policy.frostfs", "NNS name or script hash of policy contract")
Cmd.PersistentFlags().String(frostfsidHashFlag, "frostfsid.frostfs", "NNS name or script hash of frostfsid contract")
_ = Cmd.MarkPersistentFlagRequired(rpcEndpointFlag)
Cmd.AddCommand(listUserCmd)
initListUserCmd()
Cmd.AddCommand(listContainerCmd)
initListContainerCmd()
}