diff --git a/src/config/param_commit_failures.go b/src/config/param_commit_failures.go index 1cd7aa8c..f994960a 100644 --- a/src/config/param_commit_failures.go +++ b/src/config/param_commit_failures.go @@ -37,7 +37,7 @@ func AddCommitFailuresParam(cmd *cobra.Command) *BoolParam { }, cobraSettings: cobraSettings{ name: "commit-failures", - shorthand: "f", + shorthand: "F", usage: "enable committing reverts on tests failure", persistent: true, }, diff --git a/src/config/param_flavor.go b/src/config/param_flavor.go new file mode 100644 index 00000000..19c24133 --- /dev/null +++ b/src/config/param_flavor.go @@ -0,0 +1,52 @@ +/* +Copyright (c) 2024 Murex + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +package config + +import ( + "github.com/spf13/cobra" +) + +// AddFlavorParam adds flavor parameter to the provided command +func AddFlavorParam(cmd *cobra.Command) *StringParam { + param := StringParam{ + s: paramSettings{ + viperSettings: viperSettings{ + enabled: true, + keyPath: "config.tcr", + name: "flavor", + }, + cobraSettings: cobraSettings{ + name: "flavor", + shorthand: "f", + usage: "indicate the flavor to be used by TCR: nice (default) or original", + persistent: true, + }, + }, + v: paramValueString{ + value: "", + defaultValue: "nice", + }, + } + param.addToCommand(cmd) + return ¶m +} diff --git a/src/config/tcr_config.go b/src/config/tcr_config.go index 102502e6..d45d57ae 100644 --- a/src/config/tcr_config.go +++ b/src/config/tcr_config.go @@ -46,6 +46,7 @@ type TcrConfig struct { PollingPeriod *DurationParam MobTimerDuration *DurationParam AutoPush *BoolParam + Flavor *StringParam CommitFailures *BoolParam VCS *StringParam MessageSuffix *StringParam @@ -59,6 +60,7 @@ func (c TcrConfig) reset() { c.PollingPeriod.reset() c.MobTimerDuration.reset() c.AutoPush.reset() + c.Flavor.reset() c.CommitFailures.reset() c.VCS.reset() c.MessageSuffix.reset() @@ -200,6 +202,7 @@ func AddParameters(cmd *cobra.Command, defaultDir string) { Config.PollingPeriod = AddPollingPeriodParam(cmd) Config.MobTimerDuration = AddMobTimerDurationParam(cmd) Config.AutoPush = AddAutoPushParam(cmd) + Config.Flavor = AddFlavorParam(cmd) Config.CommitFailures = AddCommitFailuresParam(cmd) Config.VCS = AddVCSParam(cmd) Config.MessageSuffix = AddMessageSuffixParam(cmd) @@ -217,6 +220,7 @@ func UpdateEngineParams(p *params.Params) { p.Toolchain = Config.Toolchain.GetValue() p.PollingPeriod = Config.PollingPeriod.GetValue() p.AutoPush = Config.AutoPush.GetValue() + p.Flavor = Config.Flavor.GetValue() p.CommitFailures = Config.CommitFailures.GetValue() p.VCS = Config.VCS.GetValue() p.MessageSuffix = Config.MessageSuffix.GetValue() diff --git a/src/config/tcr_config_test.go b/src/config/tcr_config_test.go index 07dad702..69c690d1 100644 --- a/src/config/tcr_config_test.go +++ b/src/config/tcr_config_test.go @@ -241,6 +241,7 @@ func Test_show_tcr_config_with_default_values(t *testing.T) { fmt.Sprintf("%v.git.commit-failures: %v", prefix, false), fmt.Sprintf("%v.git.polling-period: %v", prefix, 2*time.Second), fmt.Sprintf("%v.mob-timer.duration: %v", prefix, 5*time.Minute), + fmt.Sprintf("%v.tcr.flavor: %v", prefix, "nice"), fmt.Sprintf("%v.tcr.language: %v", prefix, ""), fmt.Sprintf("%v.tcr.toolchain: %v", prefix, ""), fmt.Sprintf("%v.tcr.trace: %v", prefix, "none"), diff --git a/src/params/params.go b/src/params/params.go index 1b68fe0b..58f644e8 100644 --- a/src/params/params.go +++ b/src/params/params.go @@ -36,6 +36,7 @@ type Params struct { Toolchain string MobTurnDuration time.Duration AutoPush bool + Flavor string CommitFailures bool PollingPeriod time.Duration Mode runmode.RunMode diff --git a/src/params/params_test_data_builder.go b/src/params/params_test_data_builder.go index c60772cc..0edb5c70 100644 --- a/src/params/params_test_data_builder.go +++ b/src/params/params_test_data_builder.go @@ -39,6 +39,7 @@ func AParamSet(builders ...func(params *Params)) *Params { Toolchain: "", MobTurnDuration: 0, AutoPush: false, + Flavor: "", PollingPeriod: 0, Mode: runmode.OneShot{}, VCS: "git", @@ -107,6 +108,13 @@ func WithAutoPush(value bool) func(params *Params) { } } +// WithFlavor sets the provided value as the flavor to be used +func WithFlavor(flavor string) func(params *Params) { + return func(params *Params) { + params.Flavor = flavor + } +} + // WithCommitFailures sets commit-failures flag to the provided value func WithCommitFailures(value bool) func(params *Params) { return func(params *Params) {