Skip to content

Commit

Permalink
Prefer argument-based config
Browse files Browse the repository at this point in the history
  • Loading branch information
AmirrezaNasiri committed Sep 2, 2023
1 parent a024904 commit ae4338e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions commands/start_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand All @@ -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)
Expand All @@ -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
}
2 changes: 1 addition & 1 deletion tests/e2e/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ae4338e

Please sign in to comment.