From 4726b72708be2fc458413090224ead9c42f3ef83 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 4 Jul 2022 22:52:50 +1000 Subject: [PATCH] feature: Add `-windowsconsole` flag --- v2/cmd/wails/internal/commands/build/build.go | 4 ++++ v2/pkg/commands/build/base.go | 2 +- v2/pkg/commands/build/build.go | 1 + website/docs/reference/cli.mdx | 1 + 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/v2/cmd/wails/internal/commands/build/build.go b/v2/cmd/wails/internal/commands/build/build.go index 77e63728a..bffff9e52 100644 --- a/v2/cmd/wails/internal/commands/build/build.go +++ b/v2/cmd/wails/internal/commands/build/build.go @@ -102,6 +102,9 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { raceDetector := false command.BoolFlag("race", "Build with Go's race detector", &raceDetector) + windowsConsole := false + command.BoolFlag("windowsconsole", "Keep the console when building for Windows", &windowsConsole) + command.Action(func() error { quiet := verbosity == 0 @@ -184,6 +187,7 @@ func AddBuildSubcommand(app *clir.Cli, w io.Writer) { WebView2Strategy: wv2rtstrategy, TrimPath: trimpath, RaceDetector: raceDetector, + WindowsConsole: windowsConsole, } // Start a new tabwriter diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index 4825c8f50..351d944fc 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -217,7 +217,7 @@ func (b *BaseBuilder) CompileProject(options *Options) error { if options.Mode == Production { ldflags.Add("-w", "-s") - if options.Platform == "windows" { + if options.Platform == "windows" && !options.WindowsConsole { ldflags.Add("-H windowsgui") } } diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index 068433884..edc233b57 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -57,6 +57,7 @@ type Options struct { BundleName string // Bundlename for Mac TrimPath bool // Use Go's trimpath compiler flag RaceDetector bool // Build with Go's race detector + WindowsConsole bool // Indicates that the windows console should be kept } // Build the project! diff --git a/website/docs/reference/cli.mdx b/website/docs/reference/cli.mdx index 73dad026e..54259b809 100644 --- a/website/docs/reference/cli.mdx +++ b/website/docs/reference/cli.mdx @@ -71,6 +71,7 @@ A list of community maintained templates can be found [here](../community/templa | -debug | Retains debug information in the application. Allows the use of the devtools in the application window | false | | -trimpath | Remove all file system paths from the resulting executable. | false | | -race | Build with Go's race detector | false | +| -windowsconsole | Keep the console window for Windows builds | false | For a detailed description of the `webview2` flag, please refer to the [Windows](../guides/windows.mdx) Guide.