From 0c5374410629dba4d16dd5d1544fbaedcaf7cb4a Mon Sep 17 00:00:00 2001 From: Andy Maloney Date: Thu, 29 Feb 2024 10:32:54 -0500 Subject: [PATCH] No need to pass cli settings to frameworks - just the temp path --- framework/ccm_pyactr/ccm_pyactr.go | 7 +++---- framework/ccm_pyactr/ccm_pyactr_test.go | 2 +- framework/pyactr/pyactr.go | 7 +++---- framework/pyactr/pyactr_test.go | 2 +- framework/vanilla_actr/vanilla_actr.go | 7 +++---- framework/vanilla_actr/vanilla_actr_test.go | 2 +- util/frameworkutil/frameworkutil.go | 6 +++--- 7 files changed, 15 insertions(+), 18 deletions(-) diff --git a/framework/ccm_pyactr/ccm_pyactr.go b/framework/ccm_pyactr/ccm_pyactr.go index 59dd37b..c4f751d 100644 --- a/framework/ccm_pyactr/ccm_pyactr.go +++ b/framework/ccm_pyactr/ccm_pyactr.go @@ -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" @@ -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 { diff --git a/framework/ccm_pyactr/ccm_pyactr_test.go b/framework/ccm_pyactr/ccm_pyactr_test.go index 2325705..0de5557 100644 --- a/framework/ccm_pyactr/ccm_pyactr_test.go +++ b/framework/ccm_pyactr/ccm_pyactr_test.go @@ -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()) diff --git a/framework/pyactr/pyactr.go b/framework/pyactr/pyactr.go index 689825c..91f1fe9 100644 --- a/framework/pyactr/pyactr.go +++ b/framework/pyactr/pyactr.go @@ -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" @@ -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 { diff --git a/framework/pyactr/pyactr_test.go b/framework/pyactr/pyactr_test.go index a609845..2144975 100644 --- a/framework/pyactr/pyactr_test.go +++ b/framework/pyactr/pyactr_test.go @@ -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()) diff --git a/framework/vanilla_actr/vanilla_actr.go b/framework/vanilla_actr/vanilla_actr.go index c750372..58bb57c 100644 --- a/framework/vanilla_actr/vanilla_actr.go +++ b/framework/vanilla_actr/vanilla_actr.go @@ -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" @@ -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"), } diff --git a/framework/vanilla_actr/vanilla_actr_test.go b/framework/vanilla_actr/vanilla_actr_test.go index 5e5ef41..deefd51 100644 --- a/framework/vanilla_actr/vanilla_actr_test.go +++ b/framework/vanilla_actr/vanilla_actr_test.go @@ -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") diff --git a/util/frameworkutil/frameworkutil.go b/util/frameworkutil/frameworkutil.go index f5c3bc5..6ec7945 100644 --- a/util/frameworkutil/frameworkutil.go +++ b/util/frameworkutil/frameworkutil.go @@ -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)