policy-reader/modules/chains/root.go

39 lines
1 KiB
Go
Raw Normal View History

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()
}