Skip to content

Commit

Permalink
No need to pass cli settings to frameworks - just the temp path
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaloney committed Feb 29, 2024
1 parent e410414 commit 0c53744
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
7 changes: 3 additions & 4 deletions framework/ccm_pyactr/ccm_pyactr.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/asmaloney/gactar/actr"
"github.com/asmaloney/gactar/framework"

"github.com/asmaloney/gactar/util/cli"
"github.com/asmaloney/gactar/util/executil"
"github.com/asmaloney/gactar/util/filesystem"
"github.com/asmaloney/gactar/util/issues"
Expand Down Expand Up @@ -51,9 +50,9 @@ type CCMPyACTR struct {
className string
}

// New simply creates a new CCMPyACTR instance and sets the tmp path.
func New(settings *cli.Settings) (c *CCMPyACTR, err error) {
c = &CCMPyACTR{tmpPath: settings.TempPath}
// New creates a new CCMPyACTR instance and sets the temp path.
func New(tempPath string) (c *CCMPyACTR, err error) {
c = &CCMPyACTR{tmpPath: tempPath}

err = framework.Setup(&Info)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion framework/ccm_pyactr/ccm_pyactr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestCodeGeneration(t *testing.T) {
t.Fatal(err)
}

fw, err := New(ctx)
fw, err := New(ctx.TempPath)

if fw == nil {
fmt.Println(err.Error())
Expand Down
7 changes: 3 additions & 4 deletions framework/pyactr/pyactr.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/asmaloney/gactar/actr"
"github.com/asmaloney/gactar/framework"

"github.com/asmaloney/gactar/util/cli"
"github.com/asmaloney/gactar/util/executil"
"github.com/asmaloney/gactar/util/filesystem"
"github.com/asmaloney/gactar/util/issues"
Expand Down Expand Up @@ -48,9 +47,9 @@ type PyACTR struct {
className string
}

// New simply creates a new PyACTR instance and sets the tmp path from the context.
func New(settings *cli.Settings) (p *PyACTR, err error) {
p = &PyACTR{tmpPath: settings.TempPath}
// New creates a new PyACTR instance and sets the temp path.
func New(tempPath string) (p *PyACTR, err error) {
p = &PyACTR{tmpPath: tempPath}

err = framework.Setup(&Info)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion framework/pyactr/pyactr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestCodeGeneration(t *testing.T) {
t.Fatal(err)
}

fw, err := New(ctx)
fw, err := New(ctx.TempPath)

if fw == nil {
fmt.Println(err.Error())
Expand Down
7 changes: 3 additions & 4 deletions framework/vanilla_actr/vanilla_actr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/asmaloney/gactar/actr"
"github.com/asmaloney/gactar/framework"

"github.com/asmaloney/gactar/util/cli"
"github.com/asmaloney/gactar/util/executil"
"github.com/asmaloney/gactar/util/filesystem"
"github.com/asmaloney/gactar/util/issues"
Expand Down Expand Up @@ -65,10 +64,10 @@ type VanillaACTR struct {
printStatementCount int
}

// New simply creates a new VanillaACTR instance and sets some paths from the context.
func New(settings *cli.Settings) (v *VanillaACTR, err error) {
// New creates a new VanillaACTR instance and sets some paths.
func New(tempPath string) (v *VanillaACTR, err error) {
v = &VanillaACTR{
tmpPath: settings.TempPath,
tmpPath: tempPath,
envPath: os.Getenv("VIRTUAL_ENV"),
}

Expand Down
2 changes: 1 addition & 1 deletion framework/vanilla_actr/vanilla_actr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestCodeGeneration(t *testing.T) {
t.Fatal(err)
}

fw, err := New(ctx)
fw, err := New(ctx.TempPath)
if fw == nil {
fmt.Println(err.Error())
t.Skip("vanilla framework not active")
Expand Down
6 changes: 3 additions & 3 deletions util/frameworkutil/frameworkutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ func CreateFrameworks(settings *cli.Settings, names []string) (list framework.Li

switch f {
case "ccm":
fw, err = ccm_pyactr.New(settings)
fw, err = ccm_pyactr.New(settings.TempPath)

case "pyactr":
fw, err = pyactr.New(settings)
fw, err = pyactr.New(settings.TempPath)

case "vanilla":
fw, err = vanilla_actr.New(settings)
fw, err = vanilla_actr.New(settings.TempPath)

default:
chalk.PrintErrStr("unknown framework:", f)
Expand Down

0 comments on commit 0c53744

Please sign in to comment.