Skip to content

Commit c6f9ebe

Browse files
committed
Add -clean option for bindings generation.
1 parent e0c5de6 commit c6f9ebe

File tree

6 files changed

+14
-2
lines changed

6 files changed

+14
-2
lines changed

docs/src/content/docs/changelog.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3636
- `wails3 generate template` command by [@leaanthony](https://github.com/leaanthony)
3737
- `wails3 releasenotes` command by [@leaanthony](https://github.com/leaanthony)
3838
- `wails3 update cli` command by [@leaanthony](https://github.com/leaanthony)
39+
- `-clean` option for `wails3 generate bindings` command by [@leaanthony](https://github.com/leaanthony)
3940

4041
### Fixed
4142

docs/src/content/docs/guides/cli.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ wails3 generate bindings [flags] [patterns...]
144144
| `-dry` | Dry run | `false` |
145145
| `-silent` | Silent mode | `false` |
146146
| `-v` | Debug output | `false` |
147+
| `-clean` | Clean output directory | `false` |
147148

148149
### `generate build-assets`
149150
Generates build assets for your application.

v3/examples/file-association/build/Taskfile.common.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tasks:
4747
generates:
4848
- "frontend/bindings/**/*"
4949
cmds:
50-
- wails3 generate bindings -f '{{.BUILD_FLAGS}}'{{if .UseTypescript}} -ts{{end}}
50+
- wails3 generate bindings -f '{{.BUILD_FLAGS}}' -clean=true {{if .UseTypescript}} -ts{{end}}
5151

5252
generate:icons:
5353
summary: Generates Windows `.ico` and Mac `.icns` files from an image

v3/internal/commands/bindings.go

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package commands
33
import (
44
"errors"
55
"fmt"
6+
"os"
67
"path/filepath"
78

89
"github.com/pterm/pterm"
@@ -37,6 +38,13 @@ func GenerateBindings(options *flags.GenerateBindingsOptions, patterns []string)
3738
return err
3839
}
3940

41+
// Clean the output directory if clean option is enabled
42+
if options.Clean {
43+
if err := os.RemoveAll(absPath); err != nil {
44+
return fmt.Errorf("failed to clean output directory: %w", err)
45+
}
46+
}
47+
4048
// Initialise file creator.
4149
var creator config.FileCreator
4250
if !options.DryRun {

v3/internal/commands/build_assets/Taskfile.tmpl.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ tasks:
4747
generates:
4848
- "frontend/bindings/**/*"
4949
cmds:
50-
- wails3 generate bindings -f {{ "'{{.BUILD_FLAGS}}'" }} {{if .Typescript}} -ts{{end}}
50+
- wails3 generate bindings -f {{ "'{{.BUILD_FLAGS}}'" }} -clean=true {{if .Typescript}} -ts{{end}}
51+
5152
generate:icons:
5253
summary: Generates Windows `.ico` and Mac `.icns` files from an image
5354
dir: build

v3/internal/flags/bindings.go

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type GenerateBindingsOptions struct {
2121
DryRun bool `name:"dry" description:"Do not write output files"`
2222
Silent bool `name:"silent" description:"Silent mode"`
2323
Verbose bool `name:"v" description:"Enable debug output"`
24+
Clean bool `name:"clean" description:"Clean output directory before generation" default:"true"`
2425
}
2526

2627
var ErrUnmatchedQuote = errors.New("build flags contain an unmatched quote")

0 commit comments

Comments
 (0)