[#854] cli: Do not use global flags

Also delete `ttl` and `xhdr` flags from
`accounting balance` command and refactor
command initialization.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-09-27 18:36:14 +03:00 committed by Alex Vanin
parent 4ccb3d05d8
commit 8c59ade4ed
8 changed files with 562 additions and 219 deletions

View file

@ -22,18 +22,35 @@ var netmapCmd = &cobra.Command{
Use: "netmap",
Short: "Operations with Network Map",
Long: `Operations with Network Map`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// bind exactly that cmd's flags to
// the viper before execution
bindCommonFlags(cmd)
},
}
func init() {
rootCmd.AddCommand(netmapCmd)
netmapCmd.AddCommand(
netmapChildCommands := []*cobra.Command{
getEpochCmd,
localNodeInfoCmd,
netInfoCmd,
)
}
rootCmd.AddCommand(netmapCmd)
netmapCmd.AddCommand(netmapChildCommands...)
initCommonFlags(getEpochCmd)
initCommonFlags(netInfoCmd)
initCommonFlags(localNodeInfoCmd)
localNodeInfoCmd.Flags().BoolVar(&nodeInfoJSON, "json", false, "print node info in JSON format")
for _, netmapCommand := range netmapChildCommands {
flags := netmapCommand.Flags()
flags.StringSliceVarP(&xHeaders, xHeadersKey, xHeadersShorthand, xHeadersDefault, xHeadersUsage)
flags.Uint32P(ttl, ttlShorthand, ttlDefault, ttlUsage)
}
}
var getEpochCmd = &cobra.Command{