wails/v3/internal/commands/task_wrapper.go
Lea Anthony bf805b4152
Update CLI to pass through variables (#4488)
* feat: Update CLI to pass parameters through to Task commands

- Modified build and package commands to accept otherArgs parameter
- Updated task wrapper to forward CLI variables to Task
- Enhanced task.go to properly parse and handle CLI variables (KEY=VALUE format)
- Fixes issue where 'wails3 build' and 'wails3 package' commands weren't forwarding parameters

Fixes #4422

* Update changelog

* Apply suggestion from @coderabbitai[bot]

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix cli.mdx

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-08-09 21:44:30 +10:00

29 lines
915 B
Go

package commands
import (
"github.com/wailsapp/wails/v3/internal/term"
"os"
"github.com/wailsapp/wails/v3/internal/flags"
)
// runTaskFunc is a variable to allow mocking in tests
var runTaskFunc = RunTask
func Build(_ *flags.Build, otherArgs []string) error {
return wrapTask("build", otherArgs)
}
func Package(_ *flags.Package, otherArgs []string) error {
return wrapTask("package", otherArgs)
}
func wrapTask(command string, otherArgs []string) error {
term.Warningf("`wails3 %s` is an alias for `wails3 task %s`. Use `wails task` for better control and more options.\n", command, command)
// Rebuild os.Args to include the command and all additional arguments
newArgs := []string{"wails3", "task", command}
newArgs = append(newArgs, otherArgs...)
os.Args = newArgs
// Pass the task name via options and otherArgs as CLI variables
return runTaskFunc(&RunTaskOptions{Name: command}, otherArgs)
}