Skip to content

Update CLI to pass through variables - #4488

Merged
leaanthony merged 5 commits into
v3-alphafrom
vk-deec-update-cli
Aug 9, 2025
Merged

leaanthony merged 5 commits into
v3-alphafrom
vk-deec-update-cli

Conversation

@leaanthony

@leaanthony leaanthony commented Aug 9, 2025 •

Copy link
Copy Markdown
Member

Passes through variables to the in-built task commands: wails3 build and wails3 pacakge

Summary by CodeRabbit

  • New Features

    • You can now pass CLI variables to tasks using the wails3 build and wails3 package commands, allowing for more flexible task configuration.
  • Documentation

    • Updated and expanded documentation for the Wails CLI, including detailed usage instructions and examples for passing parameters to tasks and using the task command.
  • Bug Fixes

    • Improved handling and parsing of CLI variables and task names for better reliability and backward compatibility.
  • Tests

    • Added comprehensive tests to verify correct parameter passing, CLI argument parsing, and backward compatibility for task execution.

- 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
@coderabbitai

coderabbitai Bot commented Aug 9, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

This update adds comprehensive documentation for passing CLI variables to tasks and refines the CLI subcommands build and package to explicitly handle flags and forward arguments. The internal task execution logic is refactored to unify task name and CLI variable parsing from multiple sources. New integration and unit tests verify correct parameter parsing and forwarding, and dependencies are updated to support testing.

Changes

Cohort / File(s) Change Summary
Documentation: Task Parameter Passing & CLI Usage
docs/src/content/docs/guides/cli.mdx, docs/src/content/docs/learn/build.mdx
Added detailed explanations and examples on passing CLI variables to tasks, introduced a new section for the task command, and clarified usage of build and package commands with optional CLI variables.
Changelog Update
v3/UNRELEASED_CHANGELOG.md
Documented new feature supporting CLI variable passing to Task commands via wails3 build and wails3 package.
CLI Command Setup Refactor
v3/cmd/wails3/main.go
Changed build and package subcommands to explicitly create and bind flag structs, enabling argument forwarding and improved flag handling.
Dependency Updates
v3/go.mod
Added direct dependency on github.com/stretchr/testify and indirect dependency on github.com/pmezard/go-difflib for testing purposes.
Task Parameter Parsing Logic
v3/internal/commands/task.go
Refactored task execution to unify task name and CLI variable parsing from explicit options, passed arguments, or legacy os.Args, and structured CLI variables into ast.Call for task execution.
Task Wrapper Refactor
v3/internal/commands/task_wrapper.go
Updated Build and Package functions to accept additional CLI arguments, reconstructed os.Args accordingly, and replaced direct RunTask calls with a mockable function variable.
Integration & Unit Tests: Task Parameter Handling
v3/internal/commands/task_integration_test.go, v3/internal/commands/task_test.go, v3/internal/commands/task_wrapper_test.go
Added integration tests for task parameter passing and CLI argument parsing, unit tests for parsing logic, and tests for wrapper functions ensuring correct argument forwarding and backward compatibility.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI (wails3)
    participant Task Wrapper
    participant Task Executor

    User->>CLI (wails3): wails3 build KEY=VALUE
    CLI (wails3)->>Task Wrapper: Build(flags, [KEY=VALUE])
    Task Wrapper->>Task Executor: RunTask(options{Name: "build"}, [KEY=VALUE])
    Task Executor->>Task Executor: Parse task name & CLI vars
    Task Executor->>Task Executor: Execute Taskfile task with vars
    Task Executor-->>Task Wrapper: Task result
    Task Wrapper-->>CLI (wails3): Result
    CLI (wails3)-->>User: Output
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Suggested labels

lgtm

Poem

A rabbit hopped through code so neat,
Passing variables, swift and fleet.
Tasks now run with custom flair,
CLI and docs in sync with care.
Tests abound, dependencies grow,
All to help your builds just flow!
🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6cda9cb and 470a5e3.

📒 Files selected for processing (1)
  • docs/src/content/docs/guides/cli.mdx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/src/content/docs/guides/cli.mdx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Run Go Tests v3 (macos-latest, 1.24)
  • GitHub Check: Run Go Tests v3 (windows-latest, 1.24)
  • GitHub Check: Run Go Tests v3 (ubuntu-latest, 1.24)
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Cloudflare Pages
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vk-deec-update-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Enhancement New feature or request labels Aug 9, 2025
@leaanthony
leaanthony changed the base branch from master to v3-alpha August 9, 2025 08:28
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Aug 9, 2025
@github-actions github-actions Bot added Documentation Improvements or additions to documentation cli v3-alpha labels Aug 9, 2025
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 9, 2025 •

Copy link
Copy Markdown

Deploying wails with  Cloudflare Pages  Cloudflare Pages

Latest commit: 470a5e3
Status: ✅  Deploy successful!
Preview URL: https://ca2917b0.wails.pages.dev
Branch Preview URL: https://vk-deec-update-cli.wails.pages.dev

View logs

@semgrep-code-wailsapp

Copy link
Copy Markdown

Semgrep found 1 ssc-cee3e6d5-d7c8-4c35-9815-076aa1ebfd49 finding:

  • v3/examples/dev/frontend/package-lock.json

Risk: Affected versions of rollup are vulnerable to Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').

Manual Review Advice: A vulnerability from this advisory is reachable if you use Rollup to bundle JavaScript with import.meta.url and the output format is set to cjs, umd, or iife formats, while allowing users to inject scriptless HTML elements with unsanitized name attributes

Fix: Upgrade this library to at least version 3.29.5 at wails/v3/examples/dev/frontend/package-lock.json:569.

Reference(s): GHSA-gcx4-mw62-g8wm, CVE-2024-47068

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🔭 Outside diff range comments (1)
docs/src/content/docs/guides/cli.mdx (1)

489-496: Reconcile tool package flags table with implementation

The existing table in docs/src/content/docs/guides/cli.mdx omits two flags and misaligns descriptions. Update it to match the ToolPackage struct:

• File: docs/src/content/docs/guides/cli.mdx (under “#### Flags” for tool package)
Replace the current table with:

#### Flags
| Flag            | Description                                               | Default |
|-----------------|-----------------------------------------------------------|---------|
| `-format`       | Package format to generate (deb, rpm, archlinux, dmg)     | `deb`   |
| `-name`         | Name of the executable to package                         | `myapp` |
| `-config`       | Path to the package configuration file                    |         |
| `-out`          | Path to the output directory                              | `.`     |
| `-background`   | Path to an optional background image for the DMG          |         |
| `-create-dmg`   | Create a DMG file (macOS only)                            | `false` |

Also remove the duplicate/conflicting flags table elsewhere in this guide.

🧹 Nitpick comments (6)
v3/cmd/wails3/main.go (2)

37-42: Forwarding args looks correct; add LongDescription to advertise CLI variables

Implementation mirrors task and correctly forwards build.OtherArgs(). Add help text to make the feature discoverable via wails3 build -h.

 build := app.NewSubCommand("build", "Build the project")
 var buildFlags flags.Build
 build.AddFlags(&buildFlags)
 build.Action(func() error {
   return commands.Build(&buildFlags, build.OtherArgs())
 })
+build.LongDescription("\nUsage: wails3 build [CLI variables...]\n\nThis command forwards CLI variables (e.g. KEY=VALUE) to the underlying Taskfile task.\nEquivalent to: wails3 task build\nExamples:\n  wails3 build PLATFORM=linux CONFIG=production")

46-51: Same here: add LongDescription for package to advertise var forwarding

Logic is good. Improve UX of -h by documenting CLI variables here too.

 pkg := app.NewSubCommand("package", "Package application")
 var pkgFlags flags.Package
 pkg.AddFlags(&pkgFlags)
 pkg.Action(func() error {
   return commands.Package(&pkgFlags, pkg.OtherArgs())
 })
+pkg.LongDescription("\nUsage: wails3 package [CLI variables...]\n\nThis command forwards CLI variables (e.g. KEY=VALUE) to the underlying Taskfile task.\nEquivalent to: wails3 task package\nExamples:\n  wails3 package VERSION=2.0.0 OUTPUT=myapp.pkg")
docs/src/content/docs/learn/build.mdx (1)

141-163: Add a short note about quoting values with spaces

Users often pass values with spaces (e.g., product names). Recommend quoting to avoid shell splitting.

 ### Passing Parameters to Tasks

 You can pass CLI variables to tasks using the `KEY=VALUE` format. These variables are forwarded through the alias commands:
@@
 wails3 package VERSION=2.0.0 OUTPUT=myapp.pkg

In your Taskfile.yml, you can access these variables using Go template syntax:
+
+Tip: If a value contains spaces, quote it:
+
+bash +wails3 build PRODUCT_NAME="My App" CONFIG="production debug" +

tasks:
  build:
    cmds:
      - echo "Building for {{.PLATFORM | default "darwin"}}"
      - go build -tags {{.CONFIG | default "debug"}} -o myapp

</blockquote></details>
<details>
<summary>v3/internal/commands/task_wrapper.go (1)</summary><blockquote>

`21-29`: **Global `os.Args` mutation has lasting side-effects**

`wrapTask` rewrites `os.Args` and never restores it.  
For a long-running CLI that may call multiple sub-commands in-process (or unit tests executed after Build/Package), this leaks mutated state.  
Consider deferring a restore of the original slice or passing arguments directly to the Task executor instead.

</blockquote></details>
<details>
<summary>v3/internal/commands/task_integration_test.go (1)</summary><blockquote>

`15-19`: **CI gating is fragile**

The tests only skip when both `CI=true` **and** `SKIP_INTEGRATION_TESTS=true`.  
Most CI environments will run the suite unexpectedly.  
Recommend skipping when _either_ variable is set or using a single well-known env flag.

</blockquote></details>
<details>
<summary>v3/internal/commands/task.go (1)</summary><blockquote>

`170-178`: **Small optimisation opportunity**

`strings.Contains(v, "=")` followed by `strings.SplitN(v, "=", 2)` scans the string twice.  
Use `idx := strings.IndexByte(v,'=')` once to find the separator and slice, mirroring the helper used in tests.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: .coderabbit.yaml**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 3f11d4e3fa2639cc7bfd5b676d44db3eb18b55b9 and a5253c7d7a134827178a99d33f1bbfeaf9552355.

</details>

<details>
<summary>📒 Files selected for processing (10)</summary>

* `docs/src/content/docs/guides/cli.mdx` (4 hunks)
* `docs/src/content/docs/learn/build.mdx` (1 hunks)
* `v3/UNRELEASED_CHANGELOG.md` (1 hunks)
* `v3/cmd/wails3/main.go` (1 hunks)
* `v3/go.mod` (2 hunks)
* `v3/internal/commands/task.go` (1 hunks)
* `v3/internal/commands/task_integration_test.go` (1 hunks)
* `v3/internal/commands/task_test.go` (1 hunks)
* `v3/internal/commands/task_wrapper.go` (1 hunks)
* `v3/internal/commands/task_wrapper_test.go` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧠 Learnings (7)</summary>

<details>
<summary>📚 Learning: 2025-02-04T23:59:43.956Z</summary>

Learnt from: fbbdev
PR: #4045
File: v3/internal/generator/render/info.go:28-68
Timestamp: 2025-02-04T23:59:43.956Z
Learning: In the Wails v3 project, internal functions are designed to panic on nil parameters as they represent contract violations, rather than adding defensive nil checks.


**Applied to files:**
- `v3/cmd/wails3/main.go`

</details>
<details>
<summary>📚 Learning: 2025-04-29T23:54:07.488Z</summary>

Learnt from: popaprozac
PR: #4256
File: v2/internal/frontend/desktop/linux/notifications.go:27-28
Timestamp: 2025-04-29T23:54:07.488Z
Learning: In Wails v2, unlike v3-alpha which has a ServiceShutdown method for services, there is no standardized teardown pattern for frontend implementations. When implementing features that require cleanup (like goroutines or resources), add explicit cleanup methods (e.g., CleanupNotifications()) that handle resource release, context cancellation, and connection closure.


**Applied to files:**
- `v3/cmd/wails3/main.go`

</details>
<details>
<summary>📚 Learning: 2024-12-02T22:00:10.339Z</summary>

Learnt from: stavros-k
PR: #3917
File: docs/astro.config.mjs:0-0
Timestamp: 2024-12-02T22:00:10.339Z
Learning: In the Wails documentation, all content under 'docs/src/content/docs' is accessible at the root path '/', so links in the sidebar configuration should not include the '/docs' prefix.


**Applied to files:**
- `docs/src/content/docs/guides/cli.mdx`

</details>
<details>
<summary>📚 Learning: 2024-09-15T21:32:51.758Z</summary>

Learnt from: leaanthony
PR: #3748
File: v3/internal/templates/_common/Taskfile.tmpl.yml:18-18
Timestamp: 2024-09-15T21:32:51.758Z
Learning: In Taskfile, variables are referenced using {{ "{{variable}}" }} without the dot notation to differentiate them from Go template variables.


**Applied to files:**
- `docs/src/content/docs/guides/cli.mdx`
- `docs/src/content/docs/learn/build.mdx`
- `v3/internal/commands/task_integration_test.go`
- `v3/internal/commands/task.go`
- `v3/internal/commands/task_test.go`

</details>
<details>
<summary>📚 Learning: 2024-09-30T06:14:32.602Z</summary>

Learnt from: leaanthony
PR: #3763
File: v3/internal/commands/appimage_testfiles/main.go:295-299
Timestamp: 2024-09-30T06:14:32.602Z
Learning: In v3/internal/commands/appimage_testfiles/main.go, time.Sleep is used within a goroutine and does not block the UI thread.


**Applied to files:**
- `v3/internal/commands/task_wrapper_test.go`
- `v3/internal/commands/task_integration_test.go`

</details>
<details>
<summary>📚 Learning: 2025-01-15T22:40:58.594Z</summary>

Learnt from: fbbdev
PR: #4001
File: v3/internal/generator/testcases/aliases/main.go:65-68
Timestamp: 2025-01-15T22:40:58.594Z
Learning: Files in v3/internal/generator/testcases are test dummies used for testing purposes only. They are never compiled into the application and should not be subject to the same level of code review as production code.


**Applied to files:**
- `v3/internal/commands/task_wrapper_test.go`
- `v3/internal/commands/task_integration_test.go`

</details>
<details>
<summary>📚 Learning: 2024-09-15T11:08:01.900Z</summary>

Learnt from: leaanthony
PR: #3748
File: v3/internal/templates/_common/Taskfile.tmpl.yml:18-18
Timestamp: 2024-09-15T11:08:01.900Z
Learning: In Taskfile, variables are referenced using {{ "{{variable}}" }} without the dot notation.


**Applied to files:**
- `docs/src/content/docs/learn/build.mdx`
- `v3/internal/commands/task.go`
- `v3/internal/commands/task_test.go`

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)</summary>

* GitHub Check: Cloudflare Pages

</details>

<details>
<summary>🔇 Additional comments (7)</summary><blockquote>

<details>
<summary>v3/go.mod (2)</summary>

`54-54`: **LGTM: difflib is a transitive dep of testify**

`github.com/pmezard/go-difflib v1.0.0` as indirect is expected. Nothing to change.

---

`35-35`: **Testify usage confined to tests—no changes needed**

Confirmed via code search that there are no imports of `github.com/stretchr/testify` in non-`*_test.go` files. Keeping the direct `testify v1.10.0` requirement in `v3/go.mod` is appropriate.

</details>
<details>
<summary>v3/UNRELEASED_CHANGELOG.md (1)</summary>

`21-21`: **Changelog entry reads well and matches user-facing behavior**

Tense, scope, and references look good.

</details>
<details>
<summary>docs/src/content/docs/guides/cli.mdx (3)</summary>

`79-90`: **Nice: build usage now shows CLI variables and forwarding behavior**

Clear examples and note about forwarding. Good alignment with code.

---

`96-117`: **Package usage/forwarding docs look good**

Examples and note align with the CLI changes.

---

`120-188`: **Great new `task` section; comprehensive and consistent with feature**

This improves discoverability and matches the implementation.

</details>
<details>
<summary>v3/internal/commands/task_wrapper_test.go (1)</summary>

`65-71`: **Possible nil dereference in assertions**

If `wrapTaskInternal` returns early (e.g. future error path), `capturedOptions` remains `nil` and `capturedOptions.Name` panics.  
Add a `require.NotNil(t, capturedOptions)` before dereferencing.  



<details>
<summary>⛔ Skipped due to learnings</summary>

Learnt from: fbbdev
PR: #4045
File: v3/internal/generator/render/info.go:28-68
Timestamp: 2025-02-04T23:59:43.956Z
Learning: In the Wails v3 project, internal functions are designed to panic on nil parameters as they represent contract violations, rather than adding defensive nil checks.


Learnt from: fbbdev
PR: #4001
File: v3/internal/generator/analyse_test.go:105-107
Timestamp: 2025-01-15T22:42:09.774Z
Learning: In the FindServices function of v3/internal/generator/analyse.go, services should never be nil when err is nil. This is a design contract and any violation should result in a panic rather than being handled silently.


</details>

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread docs/src/content/docs/guides/cli.mdx Outdated
Comment thread docs/src/content/docs/guides/cli.mdx Outdated
Comment on lines +27 to +47
taskfileContent := `version: '3'

tasks:
build:
cmds:
- echo "PLATFORM={{.PLATFORM | default "default-platform"}}"
- echo "CONFIG={{.CONFIG | default "default-config"}}"
silent: true

package:
cmds:
- echo "VERSION={{.VERSION | default "1.0.0"}}"
- echo "OUTPUT={{.OUTPUT | default "output.pkg"}}"
silent: true

test:
cmds:
- echo "ENV={{.ENV | default "test"}}"
- echo "FLAGS={{.FLAGS | default "none"}}"
silent: true
`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

YAML quoting will break the test Taskfile

Nested double quotes inside another double-quoted string produce invalid shell syntax:

- echo "PLATFORM={{.PLATFORM | default "default-platform"}}"

Escape the inner quotes or switch to single quotes around the default value, e.g.:

- echo 'PLATFORM={{.PLATFORM | default "default-platform"}}'

Repeat for every similar line to avoid Taskfile parsing / shell errors.

🤖 Prompt for AI Agents
In v3/internal/commands/task_integration_test.go between lines 27 and 47, the
YAML string contains nested double quotes which cause invalid shell syntax. To
fix this, replace the inner double quotes around default values with single
quotes or escape them properly. For example, change lines like echo
"PLATFORM={{.PLATFORM | default "default-platform"}}" to use single quotes
around the default value or escape the inner quotes to ensure valid YAML and
shell syntax. Apply this fix consistently to all similar lines in the
taskfileContent string.

Comment on lines +122 to +178
// Helper function to extract the task parsing logic for testing
func parseTaskCall(options *RunTaskOptions, otherArgs []string) *ast.Call {
var tasksAndVars []string

// Check if we have a task name specified in options
if options.Name != "" {
// If task name is provided via options, use it and treat otherArgs as CLI variables
tasksAndVars = append([]string{options.Name}, otherArgs...)
} else if len(otherArgs) > 0 {
// Use otherArgs directly if provided
tasksAndVars = otherArgs
} else {
// Fall back to parsing os.Args for backward compatibility
var index int
var arg string
for index, arg = range os.Args[2:] {
if len(arg) > 0 && arg[0] != '-' {
break
}
}

for _, taskAndVar := range os.Args[index+2:] {
if taskAndVar == "--" {
break
}
tasksAndVars = append(tasksAndVars, taskAndVar)
}
}

// Default task
if len(tasksAndVars) == 0 {
tasksAndVars = []string{"default"}
}

// Parse task name and CLI variables
taskName := tasksAndVars[0]
cliVars := tasksAndVars[1:]

// Create call with CLI variables
call := &ast.Call{
Task: taskName,
Vars: &ast.Vars{},
}

// Parse CLI variables (format: KEY=VALUE)
for _, v := range cliVars {
if idx := findEquals(v); idx != -1 {
key := v[:idx]
value := v[idx+1:]
call.Vars.Set(key, ast.Var{
Value: value,
})
}
}

return call
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Test duplicates production parsing logic

parseTaskCall re-implements the same logic that RunTask executes.
If the production code regresses, these tests may still pass because they share the same bug.
Prefer testing the real RunTask workflow (with a mocked executor) rather than copying its internals.

🤖 Prompt for AI Agents
In v3/internal/commands/task_test.go between lines 122 and 178, the
parseTaskCall function duplicates the task parsing logic from the production
RunTask function, risking tests passing despite regressions. To fix this, remove
the parseTaskCall helper and instead write tests that invoke the actual RunTask
function with a mocked executor to verify behavior, ensuring tests reflect real
production code execution and catch regressions.

Comment on lines +131 to +134
// Variables to enable mocking in tests
var (
wrapTaskFunc = wrapTask
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Compilation fails – unused global wrapTaskFunc

This package-level variable is never referenced in the test file, so go test will error with “wrapTaskFunc declared but not used”.
Delete it or use it; otherwise the whole test suite won’t compile.

🤖 Prompt for AI Agents
In v3/internal/commands/task_wrapper_test.go around lines 131 to 134, the
package-level variable wrapTaskFunc is declared but never used, causing
compilation errors. To fix this, either remove the wrapTaskFunc variable
entirely if it is unnecessary, or update the test code to reference wrapTaskFunc
where mocking is intended. Ensure that all declared variables are used to avoid
compilation failures.

leaanthony and others added 3 commits August 9, 2025 20:20
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2025

Copy link
Copy Markdown

@leaanthony
leaanthony merged commit bf805b4 into v3-alpha Aug 9, 2025
@leaanthony
leaanthony deleted the vk-deec-update-cli branch August 9, 2025 11:44
@coderabbitai coderabbitai Bot mentioned this pull request Apr 12, 2026
1 task done
Grantmartin2002 pushed a commit to Grantmartin2002/wails that referenced this pull request Apr 29, 2026
* 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 wailsapp#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>
@taliesin-ai taliesin-ai added v3 and removed v3-alpha labels Aug 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli Documentation Improvements or additions to documentation Enhancement New feature or request size:XL This PR changes 500-999 lines, ignoring generated files. v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants