From ee2481574874ed18990ca00675b7e4867718bfc5 Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Tue, 31 Jan 2023 13:22:37 +0300 Subject: [PATCH] [#1889] Move flag `--config` in `cmd/frostfs-adm/internal/commonflags/flags.go` Signed-off-by: Anton Nikiforov --- cmd/frostfs-adm/internal/commonflags/flags.go | 7 +++++++ cmd/frostfs-adm/internal/modules/root.go | 7 +++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 cmd/frostfs-adm/internal/commonflags/flags.go diff --git a/cmd/frostfs-adm/internal/commonflags/flags.go b/cmd/frostfs-adm/internal/commonflags/flags.go new file mode 100644 index 0000000000..081023642a --- /dev/null +++ b/cmd/frostfs-adm/internal/commonflags/flags.go @@ -0,0 +1,7 @@ +package commonflags + +const ( + ConfigFlag = "config" + ConfigFlagShorthand = "c" + ConfigFlagUsage = "Config file" +) diff --git a/cmd/frostfs-adm/internal/modules/root.go b/cmd/frostfs-adm/internal/modules/root.go index 5563d1bb37..9e1739867e 100644 --- a/cmd/frostfs-adm/internal/modules/root.go +++ b/cmd/frostfs-adm/internal/modules/root.go @@ -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 }