diff --git a/spec/executor.go b/spec/executor.go index 7b17dc7..691ac4a 100644 --- a/spec/executor.go +++ b/spec/executor.go @@ -42,6 +42,9 @@ type ExpModel struct { // Programs ActionPrograms []string `json:"programs,omitempty"` + + // Categories + ActionCategories []string `json:"categories,omitempty"` } // ExpExecutor defines the ExpExecutor interface diff --git a/spec/model.go b/spec/model.go index 7e1d196..2bc54c5 100644 --- a/spec/model.go +++ b/spec/model.go @@ -82,6 +82,9 @@ type ExpActionCommandSpec interface { // Programs executed Programs() []string + + // Scenario categories + Categories() []string } type ExpFlagSpec interface { @@ -160,12 +163,13 @@ func (b *BaseExpModelCommandSpec) SetFlags(flags []ExpFlagSpec) { // BaseExpActionCommandSpec defines the common struct of the implementation of ExpActionCommandSpec type BaseExpActionCommandSpec struct { - ActionMatchers []ExpFlagSpec - ActionFlags []ExpFlagSpec - ActionExecutor Executor - ActionLongDesc string - ActionExample string - ActionPrograms []string + ActionMatchers []ExpFlagSpec + ActionFlags []ExpFlagSpec + ActionExecutor Executor + ActionLongDesc string + ActionExample string + ActionPrograms []string + ActionCategories []string } func (b *BaseExpActionCommandSpec) Matchers() []ExpFlagSpec { @@ -200,17 +204,22 @@ func (b *BaseExpActionCommandSpec) Programs() []string { return b.ActionPrograms } +func (b *BaseExpActionCommandSpec) Categories() []string { + return b.ActionCategories +} + // ActionModel for yaml file type ActionModel struct { - ActionName string `yaml:"action"` - ActionAliases []string `yaml:"aliases,flow,omitempty"` - ActionShortDesc string `yaml:"shortDesc"` - ActionLongDesc string `yaml:"longDesc"` - ActionMatchers []ExpFlag `yaml:"matchers,omitempty"` - ActionFlags []ExpFlag `yaml:"flags,omitempty"` - ActionExample string `yaml:"example"` - executor Executor - ActionPrograms []string `yaml:"programs,omitempty"` + ActionName string `yaml:"action"` + ActionAliases []string `yaml:"aliases,flow,omitempty"` + ActionShortDesc string `yaml:"shortDesc"` + ActionLongDesc string `yaml:"longDesc"` + ActionMatchers []ExpFlag `yaml:"matchers,omitempty"` + ActionFlags []ExpFlag `yaml:"flags,omitempty"` + ActionExample string `yaml:"example"` + executor Executor + ActionPrograms []string `yaml:"programs,omitempty"` + ActionCategories []string `yaml:"categories,omitempty"` } func (am *ActionModel) Programs() []string { @@ -269,6 +278,10 @@ func (am *ActionModel) Flags() []ExpFlagSpec { return flags } +func (am *ActionModel) Categories() []string { + return am.ActionCategories +} + type ExpPrepareModel struct { PrepareType string `yaml:"type"` PrepareFlags []ExpFlag `yaml:"flags"` diff --git a/util/spec.go b/util/spec.go index 2230ed0..2deb629 100644 --- a/util/spec.go +++ b/util/spec.go @@ -130,7 +130,8 @@ func ConvertSpecToModels(commandSpec spec.ExpModelCommandSpec, prepare spec.ExpP ) return flags }(), - ActionPrograms: action.Programs(), + ActionPrograms: action.Programs(), + ActionCategories: action.Categories(), } model.ExpActions = append(model.ExpActions, actionModel) }