forked from TrueCloudLab/frostfs-node
[#1889] Move flag --config
in cmd/frostfs-adm/internal/commonflags/flags.go
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
2b09564355
commit
ee24815748
2 changed files with 10 additions and 4 deletions
7
cmd/frostfs-adm/internal/commonflags/flags.go
Normal file
7
cmd/frostfs-adm/internal/commonflags/flags.go
Normal file
|
@ -0,0 +1,7 @@
|
|||
package commonflags
|
||||
|
||||
const (
|
||||
ConfigFlag = "config"
|
||||
ConfigFlagShorthand = "c"
|
||||
ConfigFlagUsage = "Config file"
|
||||
)
|
|
@ -3,6 +3,7 @@ package modules
|
|||
import (
|
||||
"os"
|
||||
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/config"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph"
|
||||
"github.com/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/storagecfg"
|
||||
|
@ -22,8 +23,6 @@ manage FrostFS network deployment.`,
|
|||
RunE: entryPoint,
|
||||
SilenceUsage: true,
|
||||
}
|
||||
|
||||
configFlag = "config"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -34,7 +33,7 @@ func init() {
|
|||
// use stdout as default output for cmd.Print()
|
||||
rootCmd.SetOut(os.Stdout)
|
||||
|
||||
rootCmd.PersistentFlags().StringP(configFlag, "c", "", "Config file")
|
||||
rootCmd.PersistentFlags().StringP(commonflags.ConfigFlag, commonflags.ConfigFlagShorthand, "", commonflags.ConfigFlagUsage)
|
||||
rootCmd.Flags().Bool("version", false, "Application version")
|
||||
|
||||
rootCmd.AddCommand(config.RootCmd)
|
||||
|
@ -60,7 +59,7 @@ func entryPoint(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
|
||||
func initConfig(cmd *cobra.Command) {
|
||||
configFile, err := cmd.Flags().GetString(configFlag)
|
||||
configFile, err := cmd.Flags().GetString(commonflags.ConfigFlag)
|
||||
if err != nil || configFile == "" {
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue