policy-reader/modules/contract/root.go
Denis Kirillov 7465cf0f4e Allow to use config file
Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
2024-08-28 16:19:23 +03:00

39 lines
954 B
Go

package contract
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var Cmd = &cobra.Command{
Use: "contract",
Short: "Operations with policy contract",
Long: "Operations with policy contract",
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"
)
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.MarkPersistentFlagRequired(rpcEndpointFlag)
Cmd.AddCommand(listTargetsCmd)
initListTargetsCmd()
Cmd.AddCommand(listChainNamesCmd)
initListChainNamesCmd()
Cmd.AddCommand(listChainsByPrefixCmd)
initListChainsByPrefixCmd()
}