forked from TrueCloudLab/frostfs-node
[#1120] cli: Fix printing config file in verbose
mode
It was broken since `initConfig` was made before every execution of the command and flags have not been read by cobra yet, so it was impossible to print config file path if `verbose` flag was set in command line not in config file. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
08e83a2bc7
commit
679c922e0c
4 changed files with 3 additions and 8 deletions
|
@ -27,7 +27,6 @@ var accountingCmd = &cobra.Command{
|
||||||
_ = viper.BindPFlag(walletPath, flags.Lookup(walletPath))
|
_ = viper.BindPFlag(walletPath, flags.Lookup(walletPath))
|
||||||
_ = viper.BindPFlag(address, flags.Lookup(address))
|
_ = viper.BindPFlag(address, flags.Lookup(address))
|
||||||
_ = viper.BindPFlag(rpc, flags.Lookup(rpc))
|
_ = viper.BindPFlag(rpc, flags.Lookup(rpc))
|
||||||
_ = viper.BindPFlag(verbose, flags.Lookup(verbose))
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +66,6 @@ func initAccountingBalanceCmd() {
|
||||||
ff.StringP(walletPath, walletPathShorthand, walletPathDefault, walletPathUsage)
|
ff.StringP(walletPath, walletPathShorthand, walletPathDefault, walletPathUsage)
|
||||||
ff.StringP(address, addressShorthand, addressDefault, addressUsage)
|
ff.StringP(address, addressShorthand, addressDefault, addressUsage)
|
||||||
ff.StringP(rpc, rpcShorthand, rpcDefault, rpcUsage)
|
ff.StringP(rpc, rpcShorthand, rpcDefault, rpcUsage)
|
||||||
ff.BoolP(verbose, verboseShorthand, verboseDefault, verboseUsage)
|
|
||||||
|
|
||||||
accountingBalanceCmd.Flags().StringVar(&balanceOwner, "owner", "", "owner of balance account (omit to use owner from private key)")
|
accountingBalanceCmd.Flags().StringVar(&balanceOwner, "owner", "", "owner of balance account (omit to use owner from private key)")
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ var controlCmd = &cobra.Command{
|
||||||
_ = viper.BindPFlag(walletPath, ff.Lookup(walletPath))
|
_ = viper.BindPFlag(walletPath, ff.Lookup(walletPath))
|
||||||
_ = viper.BindPFlag(address, ff.Lookup(address))
|
_ = viper.BindPFlag(address, ff.Lookup(address))
|
||||||
_ = viper.BindPFlag(controlRPC, ff.Lookup(controlRPC))
|
_ = viper.BindPFlag(controlRPC, ff.Lookup(controlRPC))
|
||||||
_ = viper.BindPFlag(verbose, ff.Lookup(verbose))
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,9 @@ func init() {
|
||||||
// Cobra supports persistent flags, which, if defined here,
|
// Cobra supports persistent flags, which, if defined here,
|
||||||
// will be global for your application.
|
// will be global for your application.
|
||||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.config/neofs-cli/config.yaml)")
|
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file (default is $HOME/.config/neofs-cli/config.yaml)")
|
||||||
|
rootCmd.PersistentFlags().BoolP(verbose, verboseShorthand, verboseDefault, verboseUsage)
|
||||||
|
|
||||||
|
_ = viper.BindPFlag(verbose, rootCmd.PersistentFlags().Lookup(verbose))
|
||||||
|
|
||||||
// Cobra also supports local flags, which will only run
|
// Cobra also supports local flags, which will only run
|
||||||
// when this action is called directly.
|
// when this action is called directly.
|
||||||
|
@ -409,7 +412,6 @@ func parseXHeaders() []*session.XHeader {
|
||||||
// - WIF;
|
// - WIF;
|
||||||
// - address;
|
// - address;
|
||||||
// - RPC;
|
// - RPC;
|
||||||
// - verbose;
|
|
||||||
func initCommonFlags(cmd *cobra.Command) {
|
func initCommonFlags(cmd *cobra.Command) {
|
||||||
ff := cmd.Flags()
|
ff := cmd.Flags()
|
||||||
|
|
||||||
|
@ -417,7 +419,6 @@ func initCommonFlags(cmd *cobra.Command) {
|
||||||
ff.StringP(walletPath, walletPathShorthand, walletPathDefault, walletPathUsage)
|
ff.StringP(walletPath, walletPathShorthand, walletPathDefault, walletPathUsage)
|
||||||
ff.StringP(address, addressShorthand, addressDefault, addressUsage)
|
ff.StringP(address, addressShorthand, addressDefault, addressUsage)
|
||||||
ff.StringP(rpc, rpcShorthand, rpcDefault, rpcUsage)
|
ff.StringP(rpc, rpcShorthand, rpcDefault, rpcUsage)
|
||||||
ff.BoolP(verbose, verboseShorthand, verboseDefault, verboseUsage)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// bind common command flags to the viper
|
// bind common command flags to the viper
|
||||||
|
@ -428,7 +429,6 @@ func bindCommonFlags(cmd *cobra.Command) {
|
||||||
_ = viper.BindPFlag(walletPath, ff.Lookup(walletPath))
|
_ = viper.BindPFlag(walletPath, ff.Lookup(walletPath))
|
||||||
_ = viper.BindPFlag(address, ff.Lookup(address))
|
_ = viper.BindPFlag(address, ff.Lookup(address))
|
||||||
_ = viper.BindPFlag(rpc, ff.Lookup(rpc))
|
_ = viper.BindPFlag(rpc, ff.Lookup(rpc))
|
||||||
_ = viper.BindPFlag(verbose, ff.Lookup(verbose))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func bindAPIFlags(cmd *cobra.Command) {
|
func bindAPIFlags(cmd *cobra.Command) {
|
||||||
|
|
|
@ -35,7 +35,6 @@ var (
|
||||||
_ = viper.BindPFlag(generateKey, flags.Lookup(generateKey))
|
_ = viper.BindPFlag(generateKey, flags.Lookup(generateKey))
|
||||||
_ = viper.BindPFlag(walletPath, flags.Lookup(walletPath))
|
_ = viper.BindPFlag(walletPath, flags.Lookup(walletPath))
|
||||||
_ = viper.BindPFlag(address, flags.Lookup(address))
|
_ = viper.BindPFlag(address, flags.Lookup(address))
|
||||||
_ = viper.BindPFlag(verbose, flags.Lookup(verbose))
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +193,6 @@ func initCommonFlagsWithoutRPC(cmd *cobra.Command) {
|
||||||
flags.BoolP(generateKey, generateKeyShorthand, generateKeyDefault, generateKeyUsage)
|
flags.BoolP(generateKey, generateKeyShorthand, generateKeyDefault, generateKeyUsage)
|
||||||
flags.StringP(walletPath, walletPathShorthand, walletPathDefault, walletPathUsage)
|
flags.StringP(walletPath, walletPathShorthand, walletPathDefault, walletPathUsage)
|
||||||
flags.StringP(address, addressShorthand, addressDefault, addressUsage)
|
flags.StringP(address, addressShorthand, addressDefault, addressUsage)
|
||||||
flags.BoolP(verbose, verboseShorthand, verboseDefault, verboseUsage)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func initUtilSignBearerCmd() {
|
func initUtilSignBearerCmd() {
|
||||||
|
|
Loading…
Reference in a new issue