summaryrefslogtreecommitdiff
path: root/internal/cli
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2023-10-28 12:53:43 +0200
committerValery Piashchynski <[email protected]>2023-10-28 12:53:43 +0200
commit64b4d4feb4b3abe51d8149983060c0090e4fd075 (patch)
tree2c81d7b5383c2aa4852f49d16d28013148e06a25 /internal/cli
parentb5acfd6212252c1977990e88f416b2d813939a03 (diff)
feature: flag to enable/disable experimental features
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'internal/cli')
-rw-r--r--internal/cli/root.go5
-rw-r--r--internal/cli/serve/command.go15
-rw-r--r--internal/cli/serve/command_test.go4
3 files changed, 14 insertions, 10 deletions
diff --git a/internal/cli/root.go b/internal/cli/root.go
index 1de50c43..feae0ee3 100644
--- a/internal/cli/root.go
+++ b/internal/cli/root.go
@@ -42,6 +42,8 @@ func NewCommand(cmdName string) *cobra.Command { //nolint:funlen,gocognit
override := &[]string{}
// do not print startup message
silent := toPtr(false)
+ // enable experimental features
+ experimental := toPtr(false)
// working directory
var workDir string
@@ -146,6 +148,7 @@ func NewCommand(cmdName string) *cobra.Command { //nolint:funlen,gocognit
f := cmd.PersistentFlags()
+ f.BoolVarP(experimental, "enable-experimental", "e", false, "enable experimental features")
f.BoolVarP(forceStop, "force", "f", false, "force stop")
f.BoolVarP(pidFile, "pid", "p", false, "create a .pid file")
f.StringVarP(cfgFile, "config", "c", ".rr.yaml", "config file")
@@ -158,7 +161,7 @@ func NewCommand(cmdName string) *cobra.Command { //nolint:funlen,gocognit
cmd.AddCommand(
workers.NewCommand(cfgFile, override),
reset.NewCommand(cfgFile, override, silent),
- serve.NewCommand(override, cfgFile, silent),
+ serve.NewCommand(override, cfgFile, silent, experimental),
stop.NewCommand(silent, forceStop),
jobs.NewCommand(cfgFile, override, silent),
)
diff --git a/internal/cli/serve/command.go b/internal/cli/serve/command.go
index a4caa265..95aeb067 100644
--- a/internal/cli/serve/command.go
+++ b/internal/cli/serve/command.go
@@ -21,7 +21,7 @@ const (
)
// NewCommand creates `serve` command.
-func NewCommand(override *[]string, cfgFile *string, silent *bool) *cobra.Command { //nolint:funlen
+func NewCommand(override *[]string, cfgFile *string, silent *bool, experimental *bool) *cobra.Command { //nolint:funlen
return &cobra.Command{
Use: "serve",
Short: "Start RoadRunner server",
@@ -39,11 +39,12 @@ func NewCommand(override *[]string, cfgFile *string, silent *bool) *cobra.Comman
}
cfg := &configImpl.Plugin{
- Path: *cfgFile,
- Prefix: rrPrefix,
- Timeout: containerCfg.GracePeriod,
- Flags: *override,
- Version: meta.Version(),
+ Path: *cfgFile,
+ Prefix: rrPrefix,
+ Timeout: containerCfg.GracePeriod,
+ Flags: *override,
+ Version: meta.Version(),
+ ExperimentalFeatures: *experimental,
}
endureOptions := []endure.Options{
@@ -58,7 +59,7 @@ func NewCommand(override *[]string, cfgFile *string, silent *bool) *cobra.Comman
ll, err := container.ParseLogLevel(containerCfg.LogLevel)
if err != nil {
if !*silent {
- fmt.Printf("[WARN] Failed to parse log level, using default (error): %s\n", err)
+ fmt.Println(fmt.Errorf("[WARN] Failed to parse log level, using default (error): %w", err))
}
}
cont := endure.New(ll, endureOptions...)
diff --git a/internal/cli/serve/command_test.go b/internal/cli/serve/command_test.go
index 69ff64f0..80da3949 100644
--- a/internal/cli/serve/command_test.go
+++ b/internal/cli/serve/command_test.go
@@ -10,14 +10,14 @@ import (
func TestCommandProperties(t *testing.T) {
path := ""
- cmd := serve.NewCommand(nil, &path, nil)
+ cmd := serve.NewCommand(nil, &path, nil, nil)
assert.Equal(t, "serve", cmd.Use)
assert.NotNil(t, cmd.RunE)
}
func TestCommandNil(t *testing.T) {
- cmd := serve.NewCommand(nil, nil, nil)
+ cmd := serve.NewCommand(nil, nil, nil, nil)
assert.Equal(t, "serve", cmd.Use)
assert.NotNil(t, cmd.RunE)