From ae4338e371c9bfd7a119e844dd5be9ffb5d01a2e Mon Sep 17 00:00:00 2001 From: Amirreza Nasiri Date: Sun, 3 Sep 2023 02:46:22 +0330 Subject: [PATCH] Prefer argument-based config --- commands/start_command.go | 16 +++++++--------- tests/e2e/utils_test.go | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/commands/start_command.go b/commands/start_command.go index f9ae367..762b404 100644 --- a/commands/start_command.go +++ b/commands/start_command.go @@ -11,11 +11,11 @@ import ( func GetStartCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "start", + Use: "start [flags] [CONFIG]", Short: "Start the Kermoo foreground service", + Long: "Start the Kermoo foreground service. \n\nPass your config content or the config file path to the [CONFIG] argument below. You can also pass \"-\" to read from stdin. Leaving it empty will discover config from default path or `KERMOO_CONFIG` environmetn variable. \n\nRead documentation at: https://github.com/evryn/kermoo/wiki", Run: func(cmd *cobra.Command, args []string) { - config, _ := cmd.Flags().GetString("config") - filename, _ := cmd.Flags().GetString("filename") + config, _ := cmd.Flags().GetString("filename") verbosity, _ := cmd.Flags().GetString("verbosity") if verbosity == "" { @@ -24,9 +24,8 @@ func GetStartCommand() *cobra.Command { logger.MustInitLogger(verbosity) - if filename != "" { - logger.Log.Warn("`filename` flag is deprecated and will be removed in a future major release. use `config` flag instead.") - config = filename + if len(args) == 1 { + config = args[0] } user_config.MustLoadPreparedConfig(config) @@ -40,9 +39,8 @@ func GetStartCommand() *cobra.Command { }, } - cmd.Flags().StringP("filename", "f", "", "Alias to `config` flag") - cmd.Flags().StringP("config", "c", "", "Your YAML or JSON config content or path to a config file") - cmd.Flags().StringP("verbosity", "v", "", "Verbosity level of logging output. Valid values are: debug, info") + cmd.Flags().StringP("filename", "f", "", "(Deprecated) Content of config or path to file. Use [CONFIG] placeholder argument instead. It will be removed in future versions.") + cmd.Flags().StringP("verbosity", "v", "", "Verbosity level of logging output, including: debug, info, warning, error, fatal. It overrides KERMOO_VERBOSITY environment variable.") return cmd } diff --git a/tests/e2e/utils_test.go b/tests/e2e/utils_test.go index fa9c9b1..4076b06 100644 --- a/tests/e2e/utils_test.go +++ b/tests/e2e/utils_test.go @@ -147,7 +147,7 @@ func (e *E2E) StartBinary(config string, timeout time.Duration) { var mw io.Writer - e.cmd = exec.CommandContext(e.context, e.GetKermooBinaryPath(), "start", "-v", "debug", "-f", "-") + e.cmd = exec.CommandContext(e.context, e.GetKermooBinaryPath(), "start", "-v", "debug", "-") //mw = io.MultiWriter(os.Stdout, e.GetFileLogWriter(), &e.out) mw = io.MultiWriter(e.GetFileLogWriter(), &e.out)