Skip to content

Commit

Permalink
feature: add scenario categories in model
Browse files Browse the repository at this point in the history
Signed-off-by: xcaspar <[email protected]>
  • Loading branch information
xcaspar authored and tiny-x committed Mar 5, 2021
1 parent 231bcc1 commit a444216
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
3 changes: 3 additions & 0 deletions spec/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type ExpModel struct {

// Programs
ActionPrograms []string `json:"programs,omitempty"`

// Categories
ActionCategories []string `json:"categories,omitempty"`
}

// ExpExecutor defines the ExpExecutor interface
Expand Down
43 changes: 28 additions & 15 deletions spec/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ type ExpActionCommandSpec interface {

// Programs executed
Programs() []string

// Scenario categories
Categories() []string
}

type ExpFlagSpec interface {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion util/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit a444216

Please sign in to comment.