diff --git a/context.go b/context.go index 2e980b7..e5f32e8 100644 --- a/context.go +++ b/context.go @@ -25,8 +25,8 @@ func (ctx *Context) handleOverride(override ...any) string { return str } -func (ctx *Context) runPipeline(entry, override string) *TaskDetail { - taskId := maa.MaaContextRunPipeline(ctx.handle, entry, override) +func (ctx *Context) runTask(entry, override string) *TaskDetail { + taskId := maa.MaaContextRunTask(ctx.handle, entry, override) if taskId == 0 { return nil } @@ -34,25 +34,25 @@ func (ctx *Context) runPipeline(entry, override string) *TaskDetail { return tasker.getTaskDetail(taskId) } -// RunPipeline runs a pipeline and returns its detail. +// RunTask runs a task and returns its detail. // It accepts an entry string and an optional override parameter which can be // a JSON string or any data type that can be marshaled to JSON. // If multiple overrides are provided, only the first one will be used. // // Example 1: // -// ctx.RunPipeline("Task", `{"Task":{"action":"Click","target":[100, 200, 100, 100]}}`) +// ctx.RunTask("Task", `{"Task":{"action":"Click","target":[100, 200, 100, 100]}}`) // // Example 2: // -// ctx.RunPipeline("Task", map[string]interface{}{ +// ctx.RunTask("Task", map[string]interface{}{ // "Task": map[string]interface{}{ // "action": "Click", // "target": []int{100, 200, 100, 100}, // } // }) -func (ctx *Context) RunPipeline(entry string, override ...any) *TaskDetail { - return ctx.runPipeline(entry, ctx.handleOverride(override...)) +func (ctx *Context) RunTask(entry string, override ...any) *TaskDetail { + return ctx.runTask(entry, ctx.handleOverride(override...)) } func (ctx *Context) runRecognition(entry, override string, img image.Image) *RecognitionDetail { diff --git a/context_test.go b/context_test.go index 0e92392..3ea4377 100644 --- a/context_test.go +++ b/context_test.go @@ -6,12 +6,12 @@ import ( "github.com/stretchr/testify/require" ) -type testContextRunPipelineAct struct { +type testContextRunTaskAct struct { t *testing.T } -func (t *testContextRunPipelineAct) Run(ctx *Context, _ *CustomActionArg) bool { - detail := ctx.RunPipeline("Test", J{ +func (t *testContextRunTaskAct) Run(ctx *Context, _ *CustomActionArg) bool { + detail := ctx.RunTask("Test", J{ "Test": J{ "action": "Click", "target": []int{100, 100, 10, 10}, @@ -21,7 +21,7 @@ func (t *testContextRunPipelineAct) Run(ctx *Context, _ *CustomActionArg) bool { return true } -func TestContext_RunPipeline(t *testing.T) { +func TestContext_RunTask(t *testing.T) { ctrl := createDbgController(t, nil) defer ctrl.Destroy() isConnected := ctrl.PostConnect().Wait().Success() @@ -34,10 +34,10 @@ func TestContext_RunPipeline(t *testing.T) { defer tasker.Destroy() taskerBind(t, tasker, ctrl, res) - ok := res.RegisterCustomAction("TestContext_RunPipelineAct", &testContextRunPipelineAct{t}) + ok := res.RegisterCustomAction("TestContext_RunPipelineAct", &testContextRunTaskAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_RunPipeline", J{ + got := tasker.PostTask("TestContext_RunPipeline", J{ "TestContext_RunPipeline": J{ "action": "Custom", "custom_action": "TestContext_RunPipelineAct", @@ -78,7 +78,7 @@ func TestContext_RunRecognition(t *testing.T) { ok := res.RegisterCustomAction("TestContext_RunRecognitionAct", &testContextRunRecognitionAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_RunRecognition", J{ + got := tasker.PostTask("TestContext_RunRecognition", J{ "TestContext_RunRecognition": J{ "next": []string{ "RunRecognition", @@ -125,7 +125,7 @@ func TestContext_RunAction(t *testing.T) { ok := res.RegisterCustomAction("TestContext_RunActionAct", &testContextRunActionAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_RunAction", J{ + got := tasker.PostTask("TestContext_RunAction", J{ "TestContext_RunAction": J{ "action": "Custom", "custom_action": "TestContext_RunActionAct", @@ -139,7 +139,7 @@ type testContextOverriderPipelineAct struct { } func (t *testContextOverriderPipelineAct) Run(ctx *Context, _ *CustomActionArg) bool { - detail1 := ctx.RunPipeline("Test", J{ + detail1 := ctx.RunTask("Test", J{ "Test": J{ "action": "Click", "target": []int{100, 100, 10, 10}, @@ -154,7 +154,7 @@ func (t *testContextOverriderPipelineAct) Run(ctx *Context, _ *CustomActionArg) }) require.True(t.t, ok) - detail2 := ctx.RunPipeline("Test") + detail2 := ctx.RunTask("Test") require.NotNil(t.t, detail2) return true } @@ -175,7 +175,7 @@ func TestContext_OverridePipeline(t *testing.T) { ok := res.RegisterCustomAction("TestContext_OverridePipelineAct", &testContextOverriderPipelineAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_OverridePipeline", J{ + got := tasker.PostTask("TestContext_OverridePipeline", J{ "TestContext_OverridePipeline": J{ "action": "Custom", "custom_action": "TestContext_OverridePipelineAct", @@ -201,7 +201,7 @@ func (t *testContextOverrideNextAct) Run(ctx *Context, _ *CustomActionArg) bool ok2 := ctx.OverrideNext("Test", []string{"TaskB"}) require.True(t.t, ok2) - detail := ctx.RunPipeline("Test") + detail := ctx.RunTask("Test") require.NotNil(t.t, detail) return true } @@ -222,7 +222,7 @@ func TestContext_OverrideNext(t *testing.T) { ok := res.RegisterCustomAction("TestContext_OverrideNextAct", &testContextOverrideNextAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_OverrideNext", J{ + got := tasker.PostTask("TestContext_OverrideNext", J{ "TestContext_OverrideNext": J{ "action": "Custom", "custom_action": "TestContext_OverrideNextAct", @@ -257,7 +257,7 @@ func TestContext_GetTaskJob(t *testing.T) { ok := res.RegisterCustomAction("TestContext_GetTaskJobAct", &testContextGetTaskJobAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_GetTaskJob", J{ + got := tasker.PostTask("TestContext_GetTaskJob", J{ "TestContext_GetTaskJob": J{ "action": "Custom", "custom_action": "TestContext_GetTaskJobAct", @@ -292,7 +292,7 @@ func TestContext_GetTasker(t *testing.T) { ok := res.RegisterCustomAction("TestContext_GetTaskerAct", &testContextGetTaskerAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_GetTasker", J{ + got := tasker.PostTask("TestContext_GetTasker", J{ "TestContext_GetTasker": J{ "action": "Custom", "custom_action": "TestContext_GetTaskerAct", @@ -327,7 +327,7 @@ func TestContext_Clone(t *testing.T) { ok := res.RegisterCustomAction("TestContext_GetTaskerAct", &testContextCloneAct{t}) require.True(t, ok) - got := tasker.PostPipeline("TestContext_GetTasker", J{ + got := tasker.PostTask("TestContext_GetTasker", J{ "TestContext_GetTasker": J{ "action": "Custom", "custom_action": "TestContext_GetTaskerAct", diff --git a/examples/custom-action/main.go b/examples/custom-action/main.go index ebfec11..c7e7b2c 100644 --- a/examples/custom-action/main.go +++ b/examples/custom-action/main.go @@ -2,8 +2,9 @@ package main import ( "fmt" - "github.com/MaaXYZ/maa-framework-go" "os" + + "github.com/MaaXYZ/maa-framework-go" ) func main() { @@ -28,7 +29,7 @@ func main() { res := maa.NewResource(nil) defer res.Destroy() - res.PostPath("./resource").Wait() + res.PostBundle("./resource").Wait() tasker.BindResource(res) if tasker.Initialized() { fmt.Println("Failed to init MAA.") @@ -37,7 +38,7 @@ func main() { res.RegisterCustomAction("MyAct", &MyAct{}) - detail := tasker.PostPipeline("Startup").Wait().GetDetail() + detail := tasker.PostTask("Startup").Wait().GetDetail() fmt.Println(detail) } diff --git a/examples/custom-recognition/main.go b/examples/custom-recognition/main.go index 60ef49c..f98c927 100644 --- a/examples/custom-recognition/main.go +++ b/examples/custom-recognition/main.go @@ -29,7 +29,7 @@ func main() { res := maa.NewResource(nil) defer res.Destroy() - res.PostPath("./resource").Wait() + res.PostBundle("./resource").Wait() tasker.BindResource(res) if tasker.Initialized() { fmt.Println("Failed to init MAA.") @@ -38,7 +38,7 @@ func main() { res.RegisterCustomRecognition("MyRec", &MyRec{}) - detail := tasker.PostPipeline("Startup").Wait().GetDetail() + detail := tasker.PostTask("Startup").Wait().GetDetail() fmt.Println(detail) } @@ -63,7 +63,7 @@ func (r *MyRec) Run(ctx *maa.Context, arg *maa.CustomRecognitionArg) (*maa.Custo "roi": []int{100, 200, 300, 400}, }, }) - newContext.RunPipeline("MyCustomOCR", arg.Img) + newContext.RunTask("MyCustomOCR", arg.Img) clickJob := ctx.GetTasker().GetController().PostClick(10, 20) clickJob.Wait() diff --git a/examples/quick-start/main.go b/examples/quick-start/main.go index 4296bff..a6f57dd 100644 --- a/examples/quick-start/main.go +++ b/examples/quick-start/main.go @@ -2,8 +2,9 @@ package main import ( "fmt" - "github.com/MaaXYZ/maa-framework-go" "os" + + "github.com/MaaXYZ/maa-framework-go" ) func main() { @@ -28,13 +29,13 @@ func main() { res := maa.NewResource(nil) defer res.Destroy() - res.PostPath("./resource").Wait() + res.PostBundle("./resource").Wait() tasker.BindResource(res) if tasker.Initialized() { fmt.Println("Failed to init MAA.") os.Exit(1) } - detail := tasker.PostPipeline("Startup").Wait().GetDetail() + detail := tasker.PostTask("Startup").Wait().GetDetail() fmt.Println(detail) } diff --git a/internal/maa/framework.go b/internal/maa/framework.go index 18ba98b..264b5d8 100644 --- a/internal/maa/framework.go +++ b/internal/maa/framework.go @@ -21,7 +21,7 @@ var ( MaaTaskerBindResource func(tasker uintptr, res uintptr) bool MaaTaskerBindController func(tasker uintptr, ctrl uintptr) bool MaaTaskerInited func(tasker uintptr) bool - MaaTaskerPostPipeline func(tasker uintptr, entry, pipelineOverride string) int64 + MaaTaskerPostTask func(tasker uintptr, entry, pipelineOverride string) int64 MaaTaskerStatus func(tasker uintptr, id int64) int32 MaaTaskerWait func(tasker uintptr, id int64) int32 MaaTaskerRunning func(tasker uintptr) bool @@ -29,8 +29,8 @@ var ( MaaTaskerGetResource func(tasker uintptr) uintptr MaaTaskerGetController func(tasker uintptr) uintptr MaaTaskerClearCache func(tasker uintptr) bool - MaaTaskerGetRecognitionDetail func(tasker uintptr, recoId int64, name uintptr, algorithm uintptr, hit *bool, box uintptr, detailJson uintptr, raw uintptr, draws uintptr) bool - MaaTaskerGetNodeDetail func(tasker uintptr, nodeId int64, name uintptr, recoId *int64, completed *bool) bool + MaaTaskerGetRecognitionDetail func(tasker uintptr, recoId int64, nodeName uintptr, algorithm uintptr, hit *bool, box uintptr, detailJson uintptr, raw uintptr, draws uintptr) bool + MaaTaskerGetNodeDetail func(tasker uintptr, nodeId int64, nodeName uintptr, recoId *int64, completed *bool) bool MaaTaskerGetTaskDetail func(tasker uintptr, taskId int64, entry uintptr, nodeIdList uintptr, nodeIdListSize *uint64, status *int32) bool MaaTaskerGetLatestNode func(tasker uintptr, taskName string, latestId *int64) bool ) @@ -104,7 +104,7 @@ var ( MaaResourceRegisterCustomAction func(res uintptr, name string, action MaaCustomActionCallback, transArg uintptr) bool MaaResourceUnregisterCustomAction func(res uintptr, name string) bool MaaResourceClearCustomAction func(res uintptr) bool - MaaResourcePostPath func(res uintptr, path string) int64 + MaaResourcePostBundle func(res uintptr, path string) int64 MaaResourceClear func(res uintptr) bool MaaResourceStatus func(res uintptr, id int64) int32 MaaResourceWait func(res uintptr, id int64) int32 @@ -299,11 +299,11 @@ func MaaCustomControllerCallbacksCreate( } var ( - MaaContextRunPipeline func(context uintptr, entry, pipelineOverride string) int64 + MaaContextRunTask func(context uintptr, entry, pipelineOverride string) int64 MaaContextRunRecognition func(context uintptr, entry, pipelineOverride string, image uintptr) int64 MaaContextRunAction func(context uintptr, entry, pipelineOverride string, box uintptr, recoDetail string) int64 MaaContextOverridePipeline func(context uintptr, pipelineOverride string) bool - MaaContextOverrideNext func(context uintptr, name string, nextList uintptr) bool + MaaContextOverrideNext func(context uintptr, nodeName string, nextList uintptr) bool MaaContextGetTaskId func(context uintptr) int64 MaaContextGetTasker func(context uintptr) uintptr MaaContextClone func(context uintptr) uintptr @@ -411,7 +411,7 @@ func init() { purego.RegisterLibFunc(&MaaTaskerBindResource, maaFramework, "MaaTaskerBindResource") purego.RegisterLibFunc(&MaaTaskerBindController, maaFramework, "MaaTaskerBindController") purego.RegisterLibFunc(&MaaTaskerInited, maaFramework, "MaaTaskerInited") - purego.RegisterLibFunc(&MaaTaskerPostPipeline, maaFramework, "MaaTaskerPostPipeline") + purego.RegisterLibFunc(&MaaTaskerPostTask, maaFramework, "MaaTaskerPostPipeline") purego.RegisterLibFunc(&MaaTaskerStatus, maaFramework, "MaaTaskerStatus") purego.RegisterLibFunc(&MaaTaskerWait, maaFramework, "MaaTaskerWait") purego.RegisterLibFunc(&MaaTaskerRunning, maaFramework, "MaaTaskerRunning") @@ -432,7 +432,7 @@ func init() { purego.RegisterLibFunc(&MaaResourceRegisterCustomAction, maaFramework, "MaaResourceRegisterCustomAction") purego.RegisterLibFunc(&MaaResourceUnregisterCustomAction, maaFramework, "MaaResourceUnregisterCustomAction") purego.RegisterLibFunc(&MaaResourceClearCustomAction, maaFramework, "MaaResourceClearCustomAction") - purego.RegisterLibFunc(&MaaResourcePostPath, maaFramework, "MaaResourcePostPath") + purego.RegisterLibFunc(&MaaResourcePostBundle, maaFramework, "MaaResourcePostPath") purego.RegisterLibFunc(&MaaResourceClear, maaFramework, "MaaResourceClear") purego.RegisterLibFunc(&MaaResourceStatus, maaFramework, "MaaResourceStatus") purego.RegisterLibFunc(&MaaResourceWait, maaFramework, "MaaResourceWait") @@ -464,7 +464,7 @@ func init() { purego.RegisterLibFunc(&MaaControllerCachedImage, maaFramework, "MaaControllerCachedImage") purego.RegisterLibFunc(&MaaControllerGetUuid, maaFramework, "MaaControllerGetUuid") // Context - purego.RegisterLibFunc(&MaaContextRunPipeline, maaFramework, "MaaContextRunPipeline") + purego.RegisterLibFunc(&MaaContextRunTask, maaFramework, "MaaContextRunPipeline") purego.RegisterLibFunc(&MaaContextRunRecognition, maaFramework, "MaaContextRunRecognition") purego.RegisterLibFunc(&MaaContextRunAction, maaFramework, "MaaContextRunAction") purego.RegisterLibFunc(&MaaContextOverridePipeline, maaFramework, "MaaContextOverridePipeline") diff --git a/notification_test.go b/notification_test.go index 41b8e2e..d74ab59 100644 --- a/notification_test.go +++ b/notification_test.go @@ -47,7 +47,7 @@ func TestNotificationHandler_OnRawNotification(t *testing.T) { defer tasker.Destroy() taskerBind(t, tasker, ctrl, res) - got := tasker.PostPipeline("TestNotificationHandler_OnRawNotification", J{ + got := tasker.PostTask("TestNotificationHandler_OnRawNotification", J{ "TestNotificationHandler_OnRawNotification": J{ "action": "Click", "target": []int{100, 200, 100, 100}, diff --git a/resource.go b/resource.go index 1e49b02..7c0c1fb 100644 --- a/resource.go +++ b/resource.go @@ -221,10 +221,10 @@ func (r *Resource) ClearCustomAction() bool { return maa.MaaResourceClearCustomAction(r.handle) } -// PostPath adds a path to the resource loading paths. +// PostBundle adds a path to the resource loading paths. // Return id of the resource. -func (r *Resource) PostPath(path string) *Job { - id := maa.MaaResourcePostPath(r.handle, path) +func (r *Resource) PostBundle(path string) *Job { + id := maa.MaaResourcePostBundle(r.handle, path) return NewJob(id, r.status, r.wait) } diff --git a/resource_test.go b/resource_test.go index d633821..91a3485 100644 --- a/resource_test.go +++ b/resource_test.go @@ -39,7 +39,7 @@ func TestResource_RegisterCustomRecognition(t *testing.T) { got1 := res.RegisterCustomRecognition("TestRec", &testResourceTestRec{}) require.True(t, got1) - got2 := tasker.PostPipeline("TestResource_RegisterCustomRecognition", J{ + got2 := tasker.PostTask("TestResource_RegisterCustomRecognition", J{ "TestResource_RegisterCustomRecognition": J{ "recognition": "custom", "custom_recognition": "TestRec", @@ -64,7 +64,7 @@ func TestResource_UnregisterCustomRecognition(t *testing.T) { got1 := res.RegisterCustomRecognition("TestRec", &testResourceTestRec{}) require.True(t, got1) - got2 := tasker.PostPipeline("TestResource_UnregisterCustomRecognition", J{ + got2 := tasker.PostTask("TestResource_UnregisterCustomRecognition", J{ "TestResource_UnregisterCustomRecognition": J{ "recognition": "custom", "custom_recognition": "TestRec", @@ -75,7 +75,7 @@ func TestResource_UnregisterCustomRecognition(t *testing.T) { got3 := res.UnregisterCustomRecognition("TestRec") require.True(t, got3) - got4 := tasker.PostPipeline("TestResource_UnregisterCustomRecognition", J{ + got4 := tasker.PostTask("TestResource_UnregisterCustomRecognition", J{ "TestResource_UnregisterCustomRecognition": J{ "recognition": "custom", "custom_recognition": "TestRec", @@ -102,14 +102,14 @@ func TestResource_ClearCustomRecognition(t *testing.T) { got2 := res.RegisterCustomRecognition("TestRec2", &testResourceTestRec{}) require.True(t, got2) - got3 := tasker.PostPipeline("TestResource_ClearCustomRecognition", J{ + got3 := tasker.PostTask("TestResource_ClearCustomRecognition", J{ "TestResource_ClearCustomRecognition": J{ "recognition": "custom", "custom_recognition": "TestRec1", }, }).Wait().Success() require.True(t, got3) - got4 := tasker.PostPipeline("TestResource_ClearCustomRecognition", J{ + got4 := tasker.PostTask("TestResource_ClearCustomRecognition", J{ "TestResource_ClearCustomRecognition": J{ "recognition": "custom", "custom_recognition": "TestRec2", @@ -120,14 +120,14 @@ func TestResource_ClearCustomRecognition(t *testing.T) { got5 := res.ClearCustomRecognition() require.True(t, got5) - got6 := tasker.PostPipeline("TestResource_ClearCustomRecognition", J{ + got6 := tasker.PostTask("TestResource_ClearCustomRecognition", J{ "TestResource_ClearCustomRecognition": J{ "recognition": "custom", "custom_recognition": "TestRec1", }, }).Wait().Failure() require.True(t, got6) - got7 := tasker.PostPipeline("TestResource_ClearCustomRecognition", J{ + got7 := tasker.PostTask("TestResource_ClearCustomRecognition", J{ "TestResource_ClearCustomRecognition": J{ "recognition": "custom", "custom_recognition": "TestRec2", @@ -158,7 +158,7 @@ func TestResource_RegisterCustomAction(t *testing.T) { registered := res.RegisterCustomAction("TestAct", &testResourceTestAct{}) require.True(t, registered) - got := tasker.PostPipeline("TestResource_RegisterCustomAction", J{ + got := tasker.PostTask("TestResource_RegisterCustomAction", J{ "TestResource_RegisterCustomAction": J{ "action": "custom", "custom_action": "TestAct", @@ -183,7 +183,7 @@ func TestResource_UnregisterCustomAction(t *testing.T) { registered := res.RegisterCustomAction("TestAct", &testResourceTestAct{}) require.True(t, registered) - got1 := tasker.PostPipeline("TestResource_RegisterCustomAction", J{ + got1 := tasker.PostTask("TestResource_RegisterCustomAction", J{ "TestResource_RegisterCustomAction": J{ "action": "custom", "custom_action": "TestAct", @@ -194,7 +194,7 @@ func TestResource_UnregisterCustomAction(t *testing.T) { unregistered := res.UnregisterCustomAction("TestAct") require.True(t, unregistered) - got2 := tasker.PostPipeline("TestResource_RegisterCustomAction", J{ + got2 := tasker.PostTask("TestResource_RegisterCustomAction", J{ "TestResource_RegisterCustomAction": J{ "action": "custom", "custom_action": "TestAct", @@ -221,14 +221,14 @@ func TestResource_ClearCustomAction(t *testing.T) { registered2 := res.RegisterCustomAction("TestAct2", &testResourceTestAct{}) require.True(t, registered2) - got1 := tasker.PostPipeline("TestResource_RegisterCustomAction", J{ + got1 := tasker.PostTask("TestResource_RegisterCustomAction", J{ "TestResource_RegisterCustomAction": J{ "action": "custom", "custom_action": "TestAct1", }, }).Wait().Success() require.True(t, got1) - got2 := tasker.PostPipeline("TestResource_RegisterCustomAction", J{ + got2 := tasker.PostTask("TestResource_RegisterCustomAction", J{ "TestResource_RegisterCustomAction": J{ "action": "custom", "custom_action": "TestAct2", @@ -239,14 +239,14 @@ func TestResource_ClearCustomAction(t *testing.T) { cleared := res.ClearCustomAction() require.True(t, cleared) - got3 := tasker.PostPipeline("TestResource_RegisterCustomAction", J{ + got3 := tasker.PostTask("TestResource_RegisterCustomAction", J{ "TestResource_RegisterCustomAction": J{ "action": "custom", "custom_action": "TestAct1", }, }).Wait().Failure() require.True(t, got3) - got4 := tasker.PostPipeline("TestResource_RegisterCustomAction", J{ + got4 := tasker.PostTask("TestResource_RegisterCustomAction", J{ "TestResource_RegisterCustomAction": J{ "action": "custom", "custom_action": "TestAct2", @@ -259,7 +259,7 @@ func TestResource_PostPath(t *testing.T) { res := createResource(t, nil) defer res.Destroy() resDir := "./test/data_set/PipelineSmoking/resource" - isPathSet := res.PostPath(resDir).Wait().Success() + isPathSet := res.PostBundle(resDir).Wait().Success() require.True(t, isPathSet) } @@ -267,7 +267,7 @@ func TestResource_Clear(t *testing.T) { res := createResource(t, nil) defer res.Destroy() resDir := "./test/data_set/PipelineSmoking/resource" - isPathSet := res.PostPath(resDir).Wait().Success() + isPathSet := res.PostBundle(resDir).Wait().Success() require.True(t, isPathSet) cleared := res.Clear() require.True(t, cleared) @@ -277,7 +277,7 @@ func TestResource_Loaded(t *testing.T) { res := createResource(t, nil) defer res.Destroy() resDir := "./test/data_set/PipelineSmoking/resource" - isPathSet := res.PostPath(resDir).Wait().Success() + isPathSet := res.PostBundle(resDir).Wait().Success() require.True(t, isPathSet) loaded := res.Loaded() require.True(t, loaded) @@ -287,7 +287,7 @@ func TestResource_GetHash(t *testing.T) { res := createResource(t, nil) defer res.Destroy() resDir := "./test/data_set/PipelineSmoking/resource" - isPathSet := res.PostPath(resDir).Wait().Success() + isPathSet := res.PostBundle(resDir).Wait().Success() require.True(t, isPathSet) hash, ok := res.GetHash() require.True(t, ok) @@ -298,7 +298,7 @@ func TestResource_GetTaskList(t *testing.T) { res := createResource(t, nil) defer res.Destroy() resDir := "./test/data_set/PipelineSmoking/resource" - isPathSet := res.PostPath(resDir).Wait().Success() + isPathSet := res.PostBundle(resDir).Wait().Success() require.True(t, isPathSet) taskList, ok := res.GetTaskList() require.True(t, ok) diff --git a/tasker.go b/tasker.go index 5218d68..2f9e87a 100644 --- a/tasker.go +++ b/tasker.go @@ -79,17 +79,17 @@ func (t *Tasker) handleOverride(entry string, postFunc func(entry, override stri return postFunc(entry, str) } -func (t *Tasker) postPipeline(entry, pipelineOverride string) *TaskJob { - id := maa.MaaTaskerPostPipeline(t.handle, entry, pipelineOverride) +func (t *Tasker) postTask(entry, pipelineOverride string) *TaskJob { + id := maa.MaaTaskerPostTask(t.handle, entry, pipelineOverride) return NewTaskJob(id, t.status, t.wait, t.getTaskDetail) } -// PostPipeline posts a task to the tasker. +// PostTask posts a task to the tasker. // `override` is an optional parameter. If provided, it should be a single value // that can be a JSON string or any data type that can be marshaled to JSON. // If multiple values are provided, only the first one will be used. -func (t *Tasker) PostPipeline(entry string, override ...any) *TaskJob { - return t.handleOverride(entry, t.postPipeline, override...) +func (t *Tasker) PostTask(entry string, override ...any) *TaskJob { + return t.handleOverride(entry, t.postTask, override...) } // status returns the status of a task identified by the id. diff --git a/tasker_test.go b/tasker_test.go index 9051a17..6c1bfa9 100644 --- a/tasker_test.go +++ b/tasker_test.go @@ -75,7 +75,7 @@ func TestTasker_PostPipeline(t *testing.T) { defer tasker.Destroy() taskerBind(t, tasker, ctrl, res) - taskJob := tasker.PostPipeline("TestTasker_PostPipeline", J{ + taskJob := tasker.PostTask("TestTasker_PostPipeline", J{ "TestTasker_PostPipeline": J{ "action": "Click", "target": []int{100, 200, 100, 100}, @@ -175,13 +175,13 @@ func TestTasker_GetLatestNode(t *testing.T) { res := createResource(t, nil) defer res.Destroy() resDir := "./test/data_set/PipelineSmoking/resource" - isPathSet := res.PostPath(resDir).Wait().Success() + isPathSet := res.PostBundle(resDir).Wait().Success() require.True(t, isPathSet) tasker := createTasker(t, nil) defer tasker.Destroy() taskerBind(t, tasker, ctrl, res) - job := tasker.PostPipeline("Wilderness") + job := tasker.PostTask("Wilderness") require.NotNil(t, job) time.Sleep(2 * time.Second) detail := tasker.GetLatestNode("Wilderness") diff --git a/test/pipleline_smoking_test.go b/test/pipleline_smoking_test.go index 5b13736..c3f0335 100644 --- a/test/pipleline_smoking_test.go +++ b/test/pipleline_smoking_test.go @@ -1,9 +1,10 @@ package test import ( + "testing" + "github.com/MaaXYZ/maa-framework-go" "github.com/stretchr/testify/require" - "testing" ) func TestPipelineSmoking(t *testing.T) { @@ -20,7 +21,7 @@ func TestPipelineSmoking(t *testing.T) { require.NotNil(t, res) defer res.Destroy() resDir := "./data_set/PipelineSmoking/resource" - isPathSet := res.PostPath(resDir).Wait().Success() + isPathSet := res.PostBundle(resDir).Wait().Success() require.True(t, isPathSet) tasker := maa.NewTasker(nil) @@ -34,6 +35,6 @@ func TestPipelineSmoking(t *testing.T) { isInitialized := tasker.Initialized() require.True(t, isInitialized) - got := tasker.PostPipeline("Wilderness").Wait().Success() + got := tasker.PostTask("Wilderness").Wait().Success() require.True(t, got) } diff --git a/test/run_without_file_test.go b/test/run_without_file_test.go index 4698e08..b2d9e8a 100644 --- a/test/run_without_file_test.go +++ b/test/run_without_file_test.go @@ -1,9 +1,10 @@ package test import ( + "testing" + "github.com/MaaXYZ/maa-framework-go" "github.com/stretchr/testify/require" - "testing" ) func TestRunWithoutFile(t *testing.T) { @@ -39,7 +40,7 @@ func TestRunWithoutFile(t *testing.T) { }, } - got := tasker.PostPipeline("MyTask", taskParam).Wait().Success() + got := tasker.PostTask("MyTask", taskParam).Wait().Success() require.True(t, got) }