Skip to content

Commit

Permalink
Distinguish between active frameworks and the list in the run options
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaloney committed Mar 2, 2024
1 parent 31dc92b commit 7dc932b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func setupForRun(cmd *cobra.Command) (settings *cli.Settings, err error) {
return
}

settings.Frameworks = frameworks
settings.ActiveFrameworks = frameworks

context := cli.NewContext(cmd.Context(), settings)

Expand Down
4 changes: 2 additions & 2 deletions modes/defaultmode/defaultmode.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func Initialize(settings *cli.Settings, files []string, runAfterGenerate bool) (
func (d *DefaultMode) Start() (err error) {
fmt.Printf("Intermediate file path: %q\n", d.settings.TempPath)

err = generateCode(d.settings.Frameworks, d.fileList, d.settings.TempPath)
err = generateCode(d.settings.ActiveFrameworks, d.fileList, d.settings.TempPath)
if err != nil {
return err
}

if d.runAfterGenerate {
runCode(d.settings.Frameworks)
runCode(d.settings.ActiveFrameworks)
}
return
}
Expand Down
12 changes: 6 additions & 6 deletions modes/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Initialize(settings *cli.Settings) (s *Shell, err error) {

s.preamble()

for name := range settings.Frameworks {
for name := range settings.ActiveFrameworks {
s.activeFrameworks[name] = true
}

Expand Down Expand Up @@ -158,16 +158,16 @@ func (s *Shell) cmdFramework(fNames string) (err error) {
sort.Strings(names)

if names[0] == "all" {
names = s.settings.Frameworks.Names()
names = s.settings.ActiveFrameworks.Names()
sort.Strings(names)
}

s.activeFrameworks = map[string]bool{}

for _, name := range names {
if !s.settings.Frameworks.Exists(name) {
if !s.settings.ActiveFrameworks.Exists(name) {
err = &ErrInvalidFramework{Name: name}
err = fmt.Errorf("%w. Valid values: %v", err, s.settings.Frameworks.Names())
err = fmt.Errorf("%w. Valid values: %v", err, s.settings.ActiveFrameworks.Names())
return
}

Expand Down Expand Up @@ -216,7 +216,7 @@ func (s *Shell) cmdLoad(fileName string) (err error) {
}
}

for name, f := range s.settings.Frameworks {
for name, f := range s.settings.ActiveFrameworks {
if !s.activeFrameworks[name] {
continue
}
Expand Down Expand Up @@ -249,7 +249,7 @@ func (s *Shell) cmdRun(initialGoal string) (err error) {
validate.Goal(s.currentModel, initialGoal, log)
fmt.Print(log)

for name, f := range s.settings.Frameworks {
for name, f := range s.settings.ActiveFrameworks {
if !s.activeFrameworks[name] {
continue
}
Expand Down
2 changes: 1 addition & 1 deletion modes/web/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (w Web) actrOptionsFromJSON(defaults *runoptions.Options, options *runOptio
return nil, nil
}

activeFrameworkNames := w.settings.Frameworks.Names()
activeFrameworkNames := w.settings.ActiveFrameworks.Names()

options.Frameworks.NormalizeFrameworkList(activeFrameworkNames)

Expand Down
4 changes: 2 additions & 2 deletions modes/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (w Web) getFrameworksHandler(rw http.ResponseWriter, req *http.Request) {

frameworks := framework.InfoList{}

for _, framework := range w.settings.Frameworks {
for _, framework := range w.settings.ActiveFrameworks {
frameworks = append(frameworks, *framework.Info())
}

Expand Down Expand Up @@ -208,7 +208,7 @@ func (w Web) runModel(model *actr.Model, options *runoptions.Options) (resultMap
var mutex = &sync.Mutex{}

for _, name := range options.Frameworks {
f := w.settings.Frameworks[name]
f := w.settings.ActiveFrameworks[name]

wg.Add(1)

Expand Down
2 changes: 1 addition & 1 deletion modes/web/web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestMain(m *testing.M) {

frameworks := frameworkutil.CreateFrameworks(settings, nil)

settings.Frameworks = frameworks
settings.ActiveFrameworks = frameworks

webTest, _ = Initialize(settings, 8181, nil)

Expand Down
2 changes: 1 addition & 1 deletion util/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type Settings struct {
EnvPath string // full path to the environment directory
TempPath string // full path to the temp directory

Frameworks framework.List // active frameworks
ActiveFrameworks framework.List // active frameworks (set from the command line)

Version string // the version string for output to command line
}
Expand Down
5 changes: 4 additions & 1 deletion util/runoptions/runoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ type InitialBuffers map[string]string

// Options are options used when running a model.
type Options struct {
// List of frameworks to run on (if empty, "all")
// List of frameworks to run on (if empty, "all" which means all active frameworks)
// This is used in web mode to let the user select which frameworks to run on.
// With the CLI options, this will be always be "all" since they specify the
// frameworks on the command line.
Frameworks FrameworkNameList

// Stores the initial contents of any buffers
Expand Down

0 comments on commit 7dc932b

Please sign in to comment.