diff --git a/v2/cmd/wails/build.go b/v2/cmd/wails/build.go index da4edfe17fa..33625b3c9d0 100644 --- a/v2/cmd/wails/build.go +++ b/v2/cmd/wails/build.go @@ -7,22 +7,19 @@ import ( "strings" "time" - "github.com/wailsapp/wails/v2/pkg/commands/buildtags" - "github.com/leaanthony/slicer" - "github.com/pterm/pterm" "github.com/wailsapp/wails/v2/cmd/wails/flags" "github.com/wailsapp/wails/v2/cmd/wails/internal/gomod" - "github.com/wailsapp/wails/v2/internal/colour" "github.com/wailsapp/wails/v2/internal/project" + "github.com/wailsapp/wails/v2/internal/tui" "github.com/wailsapp/wails/v2/pkg/clilogger" "github.com/wailsapp/wails/v2/pkg/commands/build" + "github.com/wailsapp/wails/v2/pkg/commands/buildtags" ) func buildApplication(f *flags.Build) error { if f.NoColour { - pterm.DisableColor() - colour.ColourEnabled = false + tui.SetNoColour() } quiet := f.Verbosity == flags.Quiet @@ -31,9 +28,7 @@ func buildApplication(f *flags.Build) error { logger := clilogger.New(os.Stdout) logger.Mute(quiet) - if quiet { - pterm.DisableOutput() - } else { + if !quiet { app.PrintBanner() } @@ -98,7 +93,7 @@ func buildApplication(f *flags.Build) error { InstallScope: f.InstallScope, } - tableData := pterm.TableData{ + tableData := [][]string{ {"Platform(s)", f.Platform}, {"Compiler", f.GetCompilerPath()}, {"Skip Bindings", bool2Str(f.SkipBindings)}, @@ -111,7 +106,7 @@ func buildApplication(f *flags.Build) error { if f.Obfuscated { tableData = append(tableData, []string{"Garble Args", f.GarbleArgs}) } - tableData = append(tableData, pterm.TableData{ + tableData = append(tableData, [][]string{ {"Skip Frontend", bool2Str(f.SkipFrontend)}, {"Compress", bool2Str(f.Upx)}, {"Package", bool2Str(!f.NoPackage)}, @@ -123,12 +118,8 @@ func buildApplication(f *flags.Build) error { if len(buildOptions.OutputFile) > 0 && f.GetTargets().Length() == 1 { tableData = append(tableData, []string{"Output File", f.OutputFilename}) } - pterm.DefaultSection.Println("Build Options") - - err = pterm.DefaultTable.WithData(tableData).Render() - if err != nil { - return err - } + tui.Section("Build Options") + tui.Table(tableData) if !f.NoSyncGoMod { err = gomod.SyncGoMod(logger, f.UpdateWailsVersionGoMod) @@ -155,8 +146,7 @@ func buildApplication(f *flags.Build) error { outputBinaries := map[string]string{} - // Allows cancelling the build after the first error. It would be nice if targets.Each would support funcs - // returning an error. + // Allows cancelling the build after the first error. var targetErr error targets := f.GetTargets() targets.Each(func(platform string) { @@ -182,23 +172,22 @@ func buildApplication(f *flags.Build) error { if len(platformSplit) > 1 { buildOptions.Arch = platformSplit[1] } - banner := "Building target: " + buildOptions.Platform + "/" + buildOptions.Arch - pterm.DefaultSection.Println(banner) + tui.Section("Building target: " + buildOptions.Platform + "/" + buildOptions.Arch) if f.Upx && platform == "darwin/universal" { - pterm.Warning.Println("Warning: compress flag unsupported for universal binaries. Ignoring.") + tui.Warning("Compress flag unsupported for universal binaries. Ignoring.") f.Upx = false } switch buildOptions.Platform { case "linux": if runtime.GOOS != "linux" { - pterm.Warning.Println("Crosscompiling to Linux not currently supported.") + tui.Warning("Crosscompiling to Linux not currently supported.") return } case "darwin": if runtime.GOOS != "darwin" { - pterm.Warning.Println("Crosscompiling to Mac not currently supported.") + tui.Warning("Crosscompiling to Mac not currently supported.") return } macTargets := targets.Filter(func(platform string) bool { @@ -210,7 +199,6 @@ func buildApplication(f *flags.Build) error { } if targets.Length() > 1 { - // target filename switch buildOptions.Platform { case "windows": desiredFilename = fmt.Sprintf("%s-%s", desiredFilename, buildOptions.Arch) @@ -228,17 +216,24 @@ func buildApplication(f *flags.Build) error { } if f.Obfuscated && f.SkipBindings { - pterm.Warning.Println("obfuscated flag overrides skipbindings flag.") + tui.Warning("Obfuscated flag overrides skipbindings flag.") buildOptions.SkipBindings = false } if !f.DryRun { - // Start Time start := time.Now() - compiledBinary, err := build.Build(buildOptions) + var compiledBinary string + err := tui.WithSpinner( + fmt.Sprintf("Compiling %s/%s", buildOptions.Platform, buildOptions.Arch), + func() error { + var buildErr error + compiledBinary, buildErr = build.Build(buildOptions) + return buildErr + }, + ) if err != nil { - pterm.Error.Println(err.Error()) + tui.Error(err.Error()) targetErr = err return } @@ -246,12 +241,10 @@ func buildApplication(f *flags.Build) error { buildOptions.IgnoreFrontend = true buildOptions.CleanBinDirectory = false - // Output stats buildOptions.Logger.Println("%s", fmt.Sprintf("Built '%s' in %s.\n", compiledBinary, time.Since(start).Round(time.Millisecond).String())) - outputBinaries[buildOptions.Platform+"/"+buildOptions.Arch] = compiledBinary } else { - pterm.Info.Println("Dry run: skipped build.") + tui.Info("Dry run: skipped build.") } }) diff --git a/v2/cmd/wails/dev.go b/v2/cmd/wails/dev.go index 30213a68e13..696ff426dfb 100644 --- a/v2/cmd/wails/dev.go +++ b/v2/cmd/wails/dev.go @@ -3,17 +3,15 @@ package main import ( "os" - "github.com/pterm/pterm" "github.com/wailsapp/wails/v2/cmd/wails/flags" "github.com/wailsapp/wails/v2/cmd/wails/internal/dev" - "github.com/wailsapp/wails/v2/internal/colour" + "github.com/wailsapp/wails/v2/internal/tui" "github.com/wailsapp/wails/v2/pkg/clilogger" ) func devApplication(f *flags.Dev) error { if f.NoColour { - pterm.DisableColor() - colour.ColourEnabled = false + tui.SetNoColour() } quiet := f.Verbosity == flags.Quiet @@ -22,9 +20,7 @@ func devApplication(f *flags.Dev) error { logger := clilogger.New(os.Stdout) logger.Mute(quiet) - if quiet { - pterm.DisableOutput() - } else { + if !quiet { app.PrintBanner() } diff --git a/v2/cmd/wails/doctor.go b/v2/cmd/wails/doctor.go index cfb0ef5c289..e8ad0ee7258 100644 --- a/v2/cmd/wails/doctor.go +++ b/v2/cmd/wails/doctor.go @@ -7,45 +7,37 @@ import ( "strconv" "strings" - "github.com/wailsapp/wails/v2/internal/shell" - - "github.com/pterm/pterm" - "github.com/jaypipes/ghw" "github.com/wailsapp/wails/v2/cmd/wails/flags" - "github.com/wailsapp/wails/v2/internal/colour" + "github.com/wailsapp/wails/v2/internal/shell" "github.com/wailsapp/wails/v2/internal/system" "github.com/wailsapp/wails/v2/internal/system/packagemanager" + "github.com/wailsapp/wails/v2/internal/tui" ) func diagnoseEnvironment(f *flags.Doctor) error { if f.NoColour { - pterm.DisableColor() - colour.ColourEnabled = false + tui.SetNoColour() } - pterm.DefaultSection = *pterm.DefaultSection. - WithBottomPadding(0). - WithStyle(pterm.NewStyle(pterm.FgBlue, pterm.Bold)) + fmt.Println() + fmt.Println(tui.Bold("Wails Doctor")) + fmt.Println() - pterm.Println() // Spacer - pterm.DefaultHeader.WithBackgroundStyle(pterm.NewStyle(pterm.BgLightBlue)).WithMargin(10).Println("Wails Doctor") - pterm.Println() // Spacer - - spinner, _ := pterm.DefaultSpinner.WithRemoveWhenDone().Start("Scanning system - Please wait (this may take a long time)...") - - // Get system info - info, err := system.GetInfo() + var info *system.Info + err := tui.WithSpinner("Scanning system", func() error { + var scanErr error + info, scanErr = system.GetInfo() + return scanErr + }) if err != nil { - spinner.Fail() - pterm.Error.Println("Failed to get system information") + tui.Error("Failed to get system information") return err } - spinner.Success() - pterm.DefaultSection.Println("Wails") + tui.Section("Wails") - wailsTableData := pterm.TableData{ + wailsTableData := [][]string{ {"Version", app.Version()}, } @@ -63,26 +55,22 @@ func diagnoseEnvironment(f *flags.Doctor) error { } } - // Exit early if PM not found if info.PM != nil { wailsTableData = append(wailsTableData, []string{"Package Manager", info.PM.Name()}) } - err = pterm.DefaultTable.WithBoxed().WithData(wailsTableData).Render() - if err != nil { - return err - } + tui.Table(wailsTableData) - pterm.DefaultSection.Println("System") + tui.Section("System") - systemTabledata := pterm.TableData{ - {pterm.Bold.Sprint("OS"), info.OS.Name}, - {pterm.Bold.Sprint("Version"), info.OS.Version}, - {pterm.Bold.Sprint("ID"), info.OS.ID}, - {pterm.Bold.Sprint("Branding"), info.OS.Branding}, - {pterm.Bold.Sprint("Go Version"), runtime.Version()}, - {pterm.Bold.Sprint("Platform"), runtime.GOOS}, - {pterm.Bold.Sprint("Architecture"), runtime.GOARCH}, + systemTabledata := [][]string{ + {"OS", info.OS.Name}, + {"Version", info.OS.Version}, + {"ID", info.OS.ID}, + {"Branding", info.OS.Branding}, + {"Go Version", runtime.Version()}, + {"Platform", runtime.GOOS}, + {"Architecture", runtime.GOARCH}, } // Probe CPU @@ -98,7 +86,6 @@ func diagnoseEnvironment(f *flags.Doctor) error { } else { cpuInfo := "Unknown" if runtime.GOOS == "darwin" { - // Try to get CPU info from sysctl if stdout, _, err := shell.RunCommand("", "sysctl", "-n", "machdep.cpu.brand_string"); err == nil { cpuInfo = strings.TrimSpace(stdout) } @@ -124,7 +111,6 @@ func diagnoseEnvironment(f *flags.Doctor) error { } else { gpuInfo := "Unknown" if runtime.GOOS == "darwin" { - // Try to get GPU info from system_profiler if stdout, _, err := shell.RunCommand("", "system_profiler", "SPDisplaysDataType"); err == nil { var ( startCapturing bool @@ -155,7 +141,6 @@ func diagnoseEnvironment(f *flags.Doctor) error { } else { memInfo := "Unknown" if runtime.GOOS == "darwin" { - // Try to get Memory info from sysctl if stdout, _, err := shell.RunCommand("", "sysctl", "-n", "hw.memsize"); err == nil { if memSize, err := strconv.Atoi(strings.TrimSpace(stdout)); err == nil { memInfo = strconv.Itoa(memSize/1024/1024/1024) + "GB" @@ -165,46 +150,38 @@ func diagnoseEnvironment(f *flags.Doctor) error { systemTabledata = append(systemTabledata, []string{"Memory", memInfo}) } - err = pterm.DefaultTable.WithBoxed().WithData(systemTabledata).Render() - if err != nil { - return err - } + tui.Table(systemTabledata) - pterm.DefaultSection.Println("Dependencies") + tui.Section("Dependencies") - // Output Dependencies Status var dependenciesMissing []string var externalPackages []*packagemanager.Dependency dependenciesAvailableRequired := 0 dependenciesAvailableOptional := 0 - dependenciesTableData := pterm.TableData{ + dependenciesTableData := [][]string{ {"Dependency", "Package Name", "Status", "Version"}, } hasOptionalDependencies := false - // Loop over dependencies for _, dependency := range info.Dependencies { name := dependency.Name if dependency.Optional { - name = pterm.Gray("*") + name + name = tui.Gray("*") + name hasOptionalDependencies = true } packageName := "Unknown" - status := pterm.LightRed("Not Found") + status := tui.Red("Not Found") - // If we found the package if dependency.PackageName != "" { packageName = dependency.PackageName - // If it's installed, update the status if dependency.Installed { - status = pterm.LightGreen("Installed") + status = tui.Green("Installed") } else { - // Generate meaningful status text - status = pterm.LightMagenta("Available") + status = tui.Magenta("Available") if dependency.Optional { dependenciesAvailableOptional++ @@ -225,38 +202,34 @@ func diagnoseEnvironment(f *flags.Doctor) error { dependenciesTableData = append(dependenciesTableData, []string{name, packageName, status, dependency.Version}) } - dependenciesTableString, _ := pterm.DefaultTable.WithHasHeader(true).WithData(dependenciesTableData).Srender() - dependenciesBox := pterm.DefaultBox.WithTitleBottomCenter() + tui.HeaderTable(dependenciesTableData) if hasOptionalDependencies { - dependenciesBox = dependenciesBox.WithTitle(pterm.Gray("*") + " - Optional Dependency") + fmt.Println("\n " + tui.Gray("*") + " = Optional Dependency") } + _ = externalPackages - dependenciesBox.Println(dependenciesTableString) - - pterm.DefaultSection.Println("Diagnosis") - - // Generate an appropriate diagnosis + tui.Section("Diagnosis") if dependenciesAvailableRequired != 0 { - pterm.Println("Required package(s) installation details: \n" + info.Dependencies.InstallAllRequiredCommand()) + fmt.Println("Required package(s) installation details:\n" + info.Dependencies.InstallAllRequiredCommand()) } if dependenciesAvailableOptional != 0 { - pterm.Println("Optional package(s) installation details: \n" + info.Dependencies.InstallAllOptionalCommand()) + fmt.Println("Optional package(s) installation details:\n" + info.Dependencies.InstallAllOptionalCommand()) } if len(dependenciesMissing) == 0 && dependenciesAvailableRequired == 0 { - pterm.Success.Println("Your system is ready for Wails development!") + tui.Success("Your system is ready for Wails development!") } else { - pterm.Warning.Println("Your system has missing dependencies!") + tui.Warning("Your system has missing dependencies!") } if len(dependenciesMissing) != 0 { - pterm.Println("Fatal:") - pterm.Println("Required dependencies missing: " + strings.Join(dependenciesMissing, " ")) + fmt.Println("Fatal:") + fmt.Println("Required dependencies missing: " + strings.Join(dependenciesMissing, " ")) } - pterm.Println() // Spacer for sponsor message + fmt.Println() return nil } diff --git a/v2/cmd/wails/generate.go b/v2/cmd/wails/generate.go index 15a6b33d868..d2e632e7437 100644 --- a/v2/cmd/wails/generate.go +++ b/v2/cmd/wails/generate.go @@ -7,13 +7,12 @@ import ( "github.com/leaanthony/debme" "github.com/leaanthony/gosod" - "github.com/pterm/pterm" "github.com/tidwall/sjson" "github.com/wailsapp/wails/v2/cmd/wails/flags" "github.com/wailsapp/wails/v2/cmd/wails/internal/template" - "github.com/wailsapp/wails/v2/internal/colour" "github.com/wailsapp/wails/v2/internal/fs" "github.com/wailsapp/wails/v2/internal/project" + "github.com/wailsapp/wails/v2/internal/tui" "github.com/wailsapp/wails/v2/pkg/clilogger" "github.com/wailsapp/wails/v2/pkg/commands/bindings" "github.com/wailsapp/wails/v2/pkg/commands/buildtags" @@ -21,8 +20,7 @@ import ( func generateModule(f *flags.GenerateModule) error { if f.NoColour { - pterm.DisableColor() - colour.ColourEnabled = false + tui.SetNoColour() } quiet := f.Verbosity == flags.Quiet @@ -47,35 +45,33 @@ func generateModule(f *flags.GenerateModule) error { projectConfig.Bindings.TsGeneration.OutputType = "classes" } - _, err = bindings.GenerateBindings(bindings.Options{ - Compiler: f.Compiler, - Tags: buildTags, - TsPrefix: projectConfig.Bindings.TsGeneration.Prefix, - TsSuffix: projectConfig.Bindings.TsGeneration.Suffix, - TsOutputType: projectConfig.Bindings.TsGeneration.OutputType, - }) - if err != nil { + err = tui.WithSpinner("Generating bindings", func() error { + _, err := bindings.GenerateBindings(bindings.Options{ + Compiler: f.Compiler, + Tags: buildTags, + TsPrefix: projectConfig.Bindings.TsGeneration.Prefix, + TsSuffix: projectConfig.Bindings.TsGeneration.Suffix, + TsOutputType: projectConfig.Bindings.TsGeneration.OutputType, + }) return err - } - return nil + }) + return err } func generateTemplate(f *flags.GenerateTemplate) error { if f.NoColour { - pterm.DisableColor() - colour.ColourEnabled = false + tui.SetNoColour() } quiet := f.Quiet logger := clilogger.New(os.Stdout) logger.Mute(quiet) + _ = logger - // name is mandatory if f.Name == "" { return fmt.Errorf("please provide a template name using the -name flag") } - // If the current directory is not empty, we create a new directory cwd, err := os.Getwd() if err != nil { return err @@ -92,18 +88,17 @@ func generateTemplate(f *flags.GenerateTemplate) error { return err } - pterm.DefaultSection.Println("Generating template") + tui.Section("Generating template") if !empty { templateDir = filepath.Join(cwd, f.Name) - printBulletPoint("Creating new template directory:", f.Name) + tui.BulletPoint("Creating new template directory: %s", f.Name) err = fs.Mkdir(templateDir) if err != nil { return err } } - // Create base template baseTemplate, err := debme.FS(template.Base, "base") if err != nil { return err @@ -123,7 +118,7 @@ func generateTemplate(f *flags.GenerateTemplate) error { WailsVersion string } - printBulletPoint("Extracting base template files...") + tui.BulletPoint("Extracting base template files...") err = g.Extract(templateDir, &templateData{ Name: f.Name, @@ -139,24 +134,21 @@ func generateTemplate(f *flags.GenerateTemplate) error { return err } - // If we aren't migrating the files, just exit if f.Frontend == "" { - pterm.Println() - pterm.Println() - pterm.Info.Println("No frontend specified to migrate. Template created.") - pterm.Println() + fmt.Println() + fmt.Println() + tui.Info("No frontend specified to migrate. Template created.") + fmt.Println() return nil } - // Remove frontend directory frontendDir := filepath.Join(templateDir, "frontend") err = os.RemoveAll(frontendDir) if err != nil { return err } - // Copy the files into a new frontend directory - printBulletPoint("Migrating existing project files to frontend directory...") + tui.BulletPoint("Migrating existing project files to frontend directory...") sourceDir, err := filepath.Abs(f.Frontend) if err != nil { @@ -169,19 +161,16 @@ func generateTemplate(f *flags.GenerateTemplate) error { return err } - // Process package.json err = processPackageJSON(frontendDir) if err != nil { return err } - // Process package-lock.json err = processPackageLockJSON(frontendDir) if err != nil { return err } - // Remove node_modules - ignore error, eg it doesn't exist _ = os.RemoveAll(filepath.Join(frontendDir, "node_modules")) return nil @@ -200,8 +189,7 @@ func processPackageJSON(frontendDir string) error { return err } - // We will ignore these errors - it's not critical - printBulletPoint("Updating package.json data...") + tui.BulletPoint("Updating package.json data...") json, _ = sjson.SetBytes(json, "name", "{{.ProjectName}}") json, _ = sjson.SetBytes(json, "author", "{{.AuthorName}}") @@ -210,7 +198,7 @@ func processPackageJSON(frontendDir string) error { return err } baseDir := filepath.Dir(packageJSON) - printBulletPoint("Renaming package.json -> package.tmpl.json...") + tui.BulletPoint("Renaming package.json -> package.tmpl.json...") err = os.Rename(packageJSON, filepath.Join(baseDir, "package.tmpl.json")) if err != nil { return err @@ -232,8 +220,7 @@ func processPackageLockJSON(frontendDir string) error { } json := string(data) - // We will ignore these errors - it's not critical - printBulletPoint("Updating package-lock.json data...") + tui.BulletPoint("Updating package-lock.json data...") json, _ = sjson.Set(json, "name", "{{.ProjectName}}") err = os.WriteFile(filename, []byte(json), 0o644) @@ -241,7 +228,7 @@ func processPackageLockJSON(frontendDir string) error { return err } baseDir := filepath.Dir(filename) - printBulletPoint("Renaming package-lock.json -> package-lock.tmpl.json...") + tui.BulletPoint("Renaming package-lock.json -> package-lock.tmpl.json...") err = os.Rename(filename, filepath.Join(baseDir, "package-lock.tmpl.json")) if err != nil { return err diff --git a/v2/cmd/wails/init.go b/v2/cmd/wails/init.go index f79e37ffc44..216b6dbe417 100644 --- a/v2/cmd/wails/init.go +++ b/v2/cmd/wails/init.go @@ -12,9 +12,8 @@ import ( "github.com/flytam/filenamify" "github.com/leaanthony/slicer" "github.com/pkg/errors" - "github.com/pterm/pterm" "github.com/wailsapp/wails/v2/cmd/wails/flags" - "github.com/wailsapp/wails/v2/internal/colour" + "github.com/wailsapp/wails/v2/internal/tui" "github.com/wailsapp/wails/v2/pkg/buildassets" "github.com/wailsapp/wails/v2/pkg/clilogger" "github.com/wailsapp/wails/v2/pkg/git" @@ -23,8 +22,7 @@ import ( func initProject(f *flags.Init) error { if f.NoColour { - pterm.DisableColor() - colour.ColourEnabled = false + tui.SetNoColour() } quiet := f.Quiet @@ -41,15 +39,15 @@ func initProject(f *flags.Init) error { return err } - pterm.DefaultSection.Println("Available templates") + tui.Section("Available templates") - table := pterm.TableData{{"Template", "Short Name", "Description"}} + table := [][]string{{"Template", "Short Name", "Description"}} for _, template := range templateList { table = append(table, []string{template.Name, template.ShortName, template.Description}) } - err = pterm.DefaultTable.WithHasHeader(true).WithBoxed(true).WithData(table).Render() - pterm.Println() - return err + tui.HeaderTable(table) + fmt.Println() + return nil } // Validate name @@ -70,7 +68,7 @@ func initProject(f *flags.Init) error { app.PrintBanner() } - pterm.DefaultSection.Printf("Initialising Project '%s'", f.ProjectName) + tui.Section(fmt.Sprintf("Initialising Project '%s'", f.ProjectName)) projectFilename, err := filenamify.Filenamify(f.ProjectName, filenamify.Options{ Replacement: "_", @@ -84,12 +82,9 @@ func initProject(f *flags.Init) error { return fmt.Errorf("unable to find Go compiler. Please download and install Go: https://golang.org/dl/") } - // Get base path and convert to forward slashes goPath := filepath.ToSlash(filepath.Dir(goBinary)) - // Trim bin directory goSDKPath := strings.TrimSuffix(goPath, "/bin") - // Create Template Options options := &templates.Options{ ProjectName: f.ProjectName, TargetDir: f.ProjectDir, @@ -102,19 +97,21 @@ func initProject(f *flags.Init) error { GoSDKPath: goSDKPath, } - // Try to discover author details from git config findAuthorDetails(options) - // Start Time start := time.Now() - // Install the template - remote, template, err := templates.Install(options) + var remote bool + var template *templates.Template + err = tui.WithSpinner("Installing template", func() error { + var installErr error + remote, template, installErr = templates.Install(options) + return installErr + }) if err != nil { return err } - // Install the default assets err = buildassets.Install(options.TargetDir) if err != nil { return err @@ -125,35 +122,33 @@ func initProject(f *flags.Init) error { return err } - // Change the module name to project name err = updateModuleNameToProjectName(options, quiet) if err != nil { return err } if !f.CIMode { - // Run `go mod tidy` to ensure `go.sum` is up to date - cmd := exec.Command("go", "mod", "tidy") - cmd.Dir = options.TargetDir - cmd.Stderr = os.Stderr - if !quiet { - cmd.Stdout = os.Stdout - } - err = cmd.Run() + err = tui.WithSpinner("Running go mod tidy", func() error { + cmd := exec.Command("go", "mod", "tidy") + cmd.Dir = options.TargetDir + cmd.Stderr = os.Stderr + if !quiet { + cmd.Stdout = os.Stdout + } + return cmd.Run() + }) if err != nil { return err } } else { - // Update go mod workspace := os.Getenv("GITHUB_WORKSPACE") - pterm.Println("GitHub workspace:", workspace) + fmt.Println("GitHub workspace:", workspace) if workspace == "" { os.Exit(1) } updateReplaceLine(workspace) } - // Remove the `.git`` directory in the template project err = os.RemoveAll(".git") if err != nil { return err @@ -170,42 +165,36 @@ func initProject(f *flags.Init) error { return nil } - // Output stats elapsed := time.Since(start) - // Create pterm table - table := pterm.TableData{ + table := [][]string{ {"Project Name", options.ProjectName}, {"Project Directory", options.TargetDir}, {"Template", template.Name}, {"Template Source", template.HelpURL}, } - err = pterm.DefaultTable.WithData(table).Render() - if err != nil { - return err - } + tui.Table(table) - // IDE message switch options.IDE { case "vscode": - pterm.Println() - pterm.Info.Println("VSCode config files generated.") + fmt.Println() + tui.Info("VSCode config files generated.") case "goland": - pterm.Println() - pterm.Info.Println("Goland config files generated.") + fmt.Println() + tui.Info("Goland config files generated.") } if options.InitGit { - pterm.Info.Println("Git repository initialised.") + tui.Info("Git repository initialised.") } if remote { - pterm.Warning.Println("NOTE: You have created a project using a remote template. The Wails project takes no responsibility for 3rd party templates. Only use remote templates that you trust.") + tui.Warning("NOTE: You have created a project using a remote template. The Wails project takes no responsibility for 3rd party templates. Only use remote templates that you trust.") } - pterm.Println("") - pterm.Printf("Initialised project '%s' in %s.\n", options.ProjectName, elapsed.Round(time.Millisecond).String()) - pterm.Println("") + fmt.Println() + fmt.Printf("Initialised project '%s' in %s.\n", options.ProjectName, elapsed.Round(time.Millisecond).String()) + fmt.Println() return nil } @@ -229,8 +218,6 @@ func initGit(options *templates.Options) error { return nil } -// findAuthorDetails tries to find the user's name and email -// from gitconfig. If it finds them, it stores them in the project options func findAuthorDetails(options *templates.Options) { if git.IsInstalled() { name, err := git.Name() @@ -269,7 +256,7 @@ func updateReplaceLine(targetPath string) { for i, line := range lines { println(line) if strings.HasPrefix(line, "// replace") { - pterm.Println("Found replace line") + fmt.Println("Found replace line") splitLine := strings.Split(line, " ") splitLine[5] = targetPath + "/v2" lines[i] = strings.Join(splitLine[1:], " ") diff --git a/v2/cmd/wails/internal/logutils/color-logs.go b/v2/cmd/wails/internal/logutils/color-logs.go index 65553df3f2a..6f1f6bda1e6 100644 --- a/v2/cmd/wails/internal/logutils/color-logs.go +++ b/v2/cmd/wails/internal/logutils/color-logs.go @@ -3,7 +3,7 @@ package logutils import ( "fmt" - "github.com/wailsapp/wails/v2/internal/colour" + "github.com/wailsapp/wails/v2/internal/tui" ) func LogGreen(message string, args ...interface{}) { @@ -11,7 +11,7 @@ func LogGreen(message string, args ...interface{}) { return } text := fmt.Sprintf(message, args...) - println(colour.Green(text)) + println(tui.Green(text)) } func LogRed(message string, args ...interface{}) { @@ -19,7 +19,7 @@ func LogRed(message string, args ...interface{}) { return } text := fmt.Sprintf(message, args...) - println(colour.Red(text)) + println(tui.Red(text)) } func LogDarkYellow(message string, args ...interface{}) { @@ -27,5 +27,5 @@ func LogDarkYellow(message string, args ...interface{}) { return } text := fmt.Sprintf(message, args...) - println(colour.DarkYellow(text)) + println(tui.DarkYellow(text)) } diff --git a/v2/cmd/wails/main.go b/v2/cmd/wails/main.go index ccf1576e9c1..2680764d884 100644 --- a/v2/cmd/wails/main.go +++ b/v2/cmd/wails/main.go @@ -3,57 +3,29 @@ package main import ( "fmt" "os" - "strings" - - "github.com/pterm/pterm" - "github.com/wailsapp/wails/v2/cmd/wails/internal" - - "github.com/wailsapp/wails/v2/internal/colour" "github.com/leaanthony/clir" + "github.com/wailsapp/wails/v2/cmd/wails/internal" + "github.com/wailsapp/wails/v2/internal/tui" ) func banner(_ *clir.Cli) string { return fmt.Sprintf("%s %s", - colour.Green("Wails CLI"), - colour.DarkRed(internal.Version)) + tui.Green("Wails CLI"), + tui.DarkRed(internal.Version)) } func fatal(message string) { - printer := pterm.PrefixPrinter{ - MessageStyle: &pterm.ThemeDefault.FatalMessageStyle, - Prefix: pterm.Prefix{ - Style: &pterm.ThemeDefault.FatalPrefixStyle, - Text: " FATAL ", - }, - } - printer.Println(message) - os.Exit(1) + tui.Fatal(message) } func printBulletPoint(text string, args ...any) { - item := pterm.BulletListItem{ - Level: 2, - Text: text, - } - t, err := pterm.DefaultBulletList.WithItems([]pterm.BulletListItem{item}).Srender() - if err != nil { - fatal(err.Error()) - } - t = strings.Trim(t, "\n\r") - pterm.Printfln(t, args...) + tui.BulletPoint(text, args...) } func printFooter() { - printer := pterm.PrefixPrinter{ - MessageStyle: pterm.NewStyle(pterm.FgLightGreen), - Prefix: pterm.Prefix{ - Style: pterm.NewStyle(pterm.FgRed, pterm.BgLightWhite), - Text: "♥ ", - }, - } - printer.Println("If Wails is useful to you or your company, please consider sponsoring the project:") - pterm.Println("https://github.com/sponsors/leaanthony") + fmt.Println(tui.Green("♥") + " If Wails is useful to you or your company, please consider sponsoring the project:") + fmt.Println(" https://github.com/sponsors/leaanthony") } func bool2Str(b bool) string { @@ -88,14 +60,14 @@ func main() { command := app.NewSubCommand("version", "The Wails CLI version") command.Action(func() error { - pterm.Println(internal.Version) + fmt.Println(internal.Version) return nil }) err = app.Run() if err != nil { - pterm.Println() - pterm.Error.Println(err.Error()) + fmt.Println() + tui.Error(err.Error()) printFooter() os.Exit(1) } diff --git a/v2/cmd/wails/show.go b/v2/cmd/wails/show.go index c83900c8df6..9b2335ab6e4 100644 --- a/v2/cmd/wails/show.go +++ b/v2/cmd/wails/show.go @@ -1,17 +1,17 @@ package main import ( - "github.com/pterm/pterm" + "fmt" + "github.com/wailsapp/wails/v2/cmd/wails/flags" "github.com/wailsapp/wails/v2/cmd/wails/internal" - "github.com/wailsapp/wails/v2/internal/colour" "github.com/wailsapp/wails/v2/internal/github" + "github.com/wailsapp/wails/v2/internal/tui" ) func showReleaseNotes(f *flags.ShowReleaseNotes) error { if f.NoColour { - pterm.DisableColor() - colour.ColourEnabled = false + tui.SetNoColour() } version := internal.Version @@ -21,7 +21,7 @@ func showReleaseNotes(f *flags.ShowReleaseNotes) error { app.PrintBanner() releaseNotes := github.GetReleaseNotes(version, f.NoColour) - pterm.Println(releaseNotes) + fmt.Println(releaseNotes) return nil } diff --git a/v2/cmd/wails/update.go b/v2/cmd/wails/update.go index 9f8b6e60462..3b2fcb6e76a 100644 --- a/v2/cmd/wails/update.go +++ b/v2/cmd/wails/update.go @@ -4,32 +4,25 @@ import ( "fmt" "os" - "github.com/labstack/gommon/color" - "github.com/pterm/pterm" "github.com/wailsapp/wails/v2/cmd/wails/flags" - "github.com/wailsapp/wails/v2/internal/colour" - "github.com/wailsapp/wails/v2/internal/shell" - "github.com/wailsapp/wails/v2/internal/github" + "github.com/wailsapp/wails/v2/internal/shell" + "github.com/wailsapp/wails/v2/internal/tui" ) -// AddSubcommand adds the `init` command for the Wails application func update(f *flags.Update) error { if f.NoColour { - colour.ColourEnabled = false - pterm.DisableColor() - + tui.SetNoColour() } - // Print banner + app.PrintBanner() - pterm.Println("Checking for updates...") + fmt.Println("Checking for updates...") var desiredVersion *github.SemanticVersion var err error var valid bool if len(f.Version) > 0 { - // Check if this is a valid version valid, err = github.IsValidTag(f.Version) if err == nil { if !valid { @@ -44,9 +37,9 @@ func update(f *flags.Update) error { } else { desiredVersion, err = github.GetLatestStableRelease() if err != nil { - pterm.Println("") - pterm.Println("No stable release found for this major version. To update to the latest pre-release (eg beta), run:") - pterm.Println(" wails update -pre") + fmt.Println() + fmt.Println("No stable release found for this major version. To update to the latest pre-release (eg beta), run:") + fmt.Println(" wails update -pre") return nil } } @@ -54,9 +47,9 @@ func update(f *flags.Update) error { if err != nil { return err } - pterm.Println() + fmt.Println() - pterm.Println(" Current Version : " + app.Version()) + fmt.Println(" Current Version : " + app.Version()) if len(f.Version) > 0 { fmt.Printf(" Desired Version : v%s\n", desiredVersion) @@ -75,14 +68,13 @@ func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentV targetVersionString := "v" + targetVersion.String() if targetVersionString == currentVersion { - pterm.Println("\nLooks like you're up to date!") + fmt.Println("\nLooks like you're up to date!") return nil } var desiredVersion string if !force { - compareVersion := currentVersion currentVersion, err := github.NewSemanticVersion(compareVersion) @@ -92,7 +84,6 @@ func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentV var success bool - // Release -> Pre-Release = Massage current version to prerelease format if targetVersion.IsPreRelease() && currentVersion.IsRelease() { testVersion, err := github.NewSemanticVersion(compareVersion + "-0") if err != nil { @@ -100,9 +91,7 @@ func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentV } success, _ = targetVersion.IsGreaterThan(testVersion) } - // Pre-Release -> Release = Massage target version to prerelease format if targetVersion.IsRelease() && currentVersion.IsPreRelease() { - // We are ok with greater than or equal mainversion := currentVersion.MainVersion() targetVersion, err = github.NewSemanticVersion(targetVersion.String()) if err != nil { @@ -111,46 +100,42 @@ func updateToVersion(targetVersion *github.SemanticVersion, force bool, currentV success, _ = targetVersion.IsGreaterThanOrEqual(mainversion) } - // Release -> Release = Standard check if (targetVersion.IsRelease() && currentVersion.IsRelease()) || (targetVersion.IsPreRelease() && currentVersion.IsPreRelease()) { - success, _ = targetVersion.IsGreaterThan(currentVersion) } - // Compare if !success { - pterm.Println("Error: The requested version is lower than the current version.") - pterm.Println(fmt.Sprintf("If this is what you really want to do, use `wails update -version "+"%s`", targetVersionString)) - + fmt.Println("Error: The requested version is lower than the current version.") + fmt.Println(fmt.Sprintf("If this is what you really want to do, use `wails update -version "+"%s`", targetVersionString)) return nil } desiredVersion = "v" + targetVersion.String() - } else { desiredVersion = "v" + targetVersion.String() } - pterm.Println() - pterm.Print("Installing Wails CLI " + desiredVersion + "...") - - // Run command in non module directory - homeDir, err := os.UserHomeDir() - if err != nil { - fatal("Cannot find home directory! Please file a bug report!") - } + fmt.Println() - sout, serr, err := shell.RunCommand(homeDir, "go", "install", "github.com/wailsapp/wails/v2/cmd/wails@"+desiredVersion) + var sout, serr string + err := tui.WithSpinner("Installing Wails CLI "+desiredVersion, func() error { + homeDir, err := os.UserHomeDir() + if err != nil { + return fmt.Errorf("cannot find home directory: %w", err) + } + sout, serr, err = shell.RunCommand(homeDir, "go", "install", "github.com/wailsapp/wails/v2/cmd/wails@"+desiredVersion) + return err + }) if err != nil { - pterm.Println("Failed.") - pterm.Error.Println(sout + `\n` + serr) + tui.Error(sout + "\n" + serr) return err } - pterm.Println("Done.") - pterm.Println(color.Green("\nMake sure you update your project go.mod file to use " + desiredVersion + ":")) - pterm.Println(color.Green(" require github.com/wailsapp/wails/v2 " + desiredVersion)) - pterm.Println(color.Red("\nTo view the release notes, please run `wails show releasenotes`")) + + fmt.Println() + fmt.Println(tui.Green("Make sure you update your project go.mod file to use " + desiredVersion + ":")) + fmt.Println(tui.Green(" require github.com/wailsapp/wails/v2 " + desiredVersion)) + fmt.Println(tui.Red("\nTo view the release notes, please run `wails show releasenotes`")) return nil } diff --git a/v2/go.mod b/v2/go.mod index e2cfcb7520c..633eaded163 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -1,6 +1,6 @@ module github.com/wailsapp/wails/v2 -go 1.25.0 +go 1.25.1 require ( git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 @@ -38,13 +38,13 @@ require ( github.com/tc-hib/winres v0.3.1 github.com/tidwall/sjson v1.2.5 github.com/tkrajina/go-reflector v0.5.8 + github.com/kungfusheep/glyph v0.6.0 github.com/wailsapp/go-webview2 v1.0.22 github.com/wailsapp/mimetype v1.4.1 - github.com/wzshiming/ctc v1.2.3 - golang.org/x/mod v0.23.0 - golang.org/x/net v0.35.0 - golang.org/x/sys v0.30.0 - golang.org/x/tools v0.30.0 + golang.org/x/mod v0.26.0 + golang.org/x/net v0.42.0 + golang.org/x/sys v0.40.0 + golang.org/x/tools v0.35.0 ) require ( @@ -52,6 +52,7 @@ require ( atomicgo.dev/keyboard v0.2.9 // indirect atomicgo.dev/schedule v0.1.0 // indirect dario.cat/mergo v1.0.0 // indirect + github.com/BurntSushi/toml v1.6.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v1.1.5 // indirect github.com/alecthomas/chroma/v2 v2.14.0 // indirect @@ -59,6 +60,8 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/charmbracelet/lipgloss v0.12.1 // indirect github.com/charmbracelet/x/ansi v0.1.4 // indirect + github.com/clipperhouse/stringish v0.1.1 // indirect + github.com/clipperhouse/uax29/v2 v2.4.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/containerd/console v1.0.3 // indirect github.com/cyphar/filepath-securejoin v0.3.6 // indirect @@ -75,12 +78,14 @@ require ( github.com/jaypipes/pcidb v1.1.1 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect + github.com/junegunn/fzf v0.67.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/kungfusheep/riffkey v0.0.0-20260216102013-df19649e3a0d // indirect github.com/lithammer/fuzzysearch v1.1.8 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect + github.com/mattn/go-runewidth v0.0.19 // indirect github.com/microcosm-cc/bluemonday v1.0.27 // indirect github.com/muesli/reflow v0.3.0 // indirect github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect @@ -95,17 +100,16 @@ require ( github.com/tidwall/pretty v1.2.0 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect - github.com/wzshiming/winseq v0.0.0-20200112104235-db357dc107ae // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect github.com/yuin/goldmark v1.7.4 // indirect github.com/yuin/goldmark-emoji v1.0.3 // indirect github.com/yusufpapurcu/wmi v1.2.4 // indirect - golang.org/x/crypto v0.33.0 // indirect + golang.org/x/crypto v0.40.0 // indirect golang.org/x/image v0.12.0 // indirect - golang.org/x/sync v0.11.0 // indirect - golang.org/x/term v0.29.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/sync v0.16.0 // indirect + golang.org/x/term v0.34.0 // indirect + golang.org/x/text v0.28.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect howett.net/plist v1.0.2-0.20250314012144-ee69052608d9 // indirect diff --git a/v2/go.sum b/v2/go.sum index 2cfe9f7abe1..67ff95b58f1 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -10,6 +10,8 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 h1:N3IGoHHp9pb6mj1cbXbuaSXV/UMKwmbKLf53nQmtqMA= git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3/go.mod h1:QtOLZGz8olr4qH2vWK0QH0w0O4T9fEIjMuWpKUsH7nc= +github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk= +github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs= github.com/MarvinJWendt/testza v0.2.1/go.mod h1:God7bhG8n6uQxwdScay+gjm9/LnO4D3kkcZX4hv9Rp8= github.com/MarvinJWendt/testza v0.2.8/go.mod h1:nwIcjmr0Zz+Rcwfh3/4UhBp7ePKVhuBExvZqnKYWlII= @@ -57,6 +59,10 @@ github.com/charmbracelet/x/ansi v0.1.4 h1:IEU3D6+dWwPSgZ6HBH+v6oUuZ/nVawMiWj5831 github.com/charmbracelet/x/ansi v0.1.4/go.mod h1:dk73KoMTT5AX5BsX0KrqhsTqAnhZZoCBjs7dGWp4Ktw= github.com/charmbracelet/x/exp/golden v0.0.0-20240715153702-9ba8adf781c4 h1:6KzMkQeAF56rggw2NZu1L+TH7j9+DM1/2Kmh7KUxg1I= github.com/charmbracelet/x/exp/golden v0.0.0-20240715153702-9ba8adf781c4/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U= +github.com/clipperhouse/stringish v0.1.1 h1:+NSqMOr3GR6k1FdRhhnXrLfztGzuG+VuFDfatpWHKCs= +github.com/clipperhouse/stringish v0.1.1/go.mod h1:v/WhFtE1q0ovMta2+m+UbpZ+2/HEXNWYXQgCt4hdOzA= +github.com/clipperhouse/uax29/v2 v2.4.0 h1:RXqE/l5EiAbA4u97giimKNlmpvkmz+GrBVTelsoXy9g= +github.com/clipperhouse/uax29/v2 v2.4.0/go.mod h1:Wn1g7MK6OoeDT0vL+Q0SQLDz/KpfsVRgg6W7ihQeh4g= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw= @@ -126,6 +132,8 @@ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck= github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/junegunn/fzf v0.67.0 h1:naiOdIkV5/ZCfHgKQIV/f5YDWowl95G6yyOQqW8FeSo= +github.com/junegunn/fzf v0.67.0/go.mod h1:xlXX2/rmsccKQUnr9QOXPDi5DyV9cM0UjKy/huScBeE= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -140,6 +148,10 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kungfusheep/glyph v0.6.0 h1:/nPdykfd7kwJAXbOPys2gH7+XLSs2BRlqmNsNIlWHjo= +github.com/kungfusheep/glyph v0.6.0/go.mod h1:jlGW9hYjGHpMGXDeoNk0i5rlI7BWt8hQhpuyAHq21gI= +github.com/kungfusheep/riffkey v0.0.0-20260216102013-df19649e3a0d h1:ff9WvfadD7BXE1fFl42eeJ4+Gn8gZolx4zFdzoIZvXk= +github.com/kungfusheep/riffkey v0.0.0-20260216102013-df19649e3a0d/go.mod h1:s+DoFavosJjxGBTgWlhrDKwpsDk0iL7lg3919Fmh6Ys= github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY= github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= @@ -176,6 +188,8 @@ github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.19 h1:v++JhqYnZuu5jSKrk9RbgF5v4CGUjqRfBm05byFGLdw= +github.com/mattn/go-runewidth v0.0.19/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk= github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= @@ -268,6 +282,7 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= +golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/image v0.0.0-20200430140353-33d19683fad8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -277,6 +292,7 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.26.0/go.mod h1:/j6NAhSk8iQ723BGAUyoAcn7SlD7s15Dp9Nd/SfeaFQ= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -285,11 +301,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -311,6 +329,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= +golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -318,6 +338,7 @@ golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= +golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -327,12 +348,14 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= +golang.org/x/tools v0.35.0/go.mod h1:NKdj5HkL/73byiZSJjqJgKn3ep7KjFkBOkR/Hps3VPw= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/v2/internal/colour/colour.go b/v2/internal/colour/colour.go index ee1ca97436b..e76230d461d 100644 --- a/v2/internal/colour/colour.go +++ b/v2/internal/colour/colour.go @@ -1,145 +1,48 @@ +// Package colour provides backward-compatible color functions. +// All functions delegate to the tui package which is the single source of truth. package colour import ( - "fmt" "strings" - "github.com/wzshiming/ctc" + "github.com/wailsapp/wails/v2/internal/tui" ) +// ColourEnabled is kept for backward compatibility. +// Use tui.SetNoColour() or tui.ColourEnabled directly instead. var ColourEnabled = true -func Col(col ctc.Color, text string) string { - if !ColourEnabled { - return text - } - return fmt.Sprintf("%s%s%s", col, text, ctc.Reset) -} - -func Yellow(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightYellow, text) -} - -func Red(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightRed, text) -} - -func Blue(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightBlue, text) -} - -func Green(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightGreen, text) -} - -func Cyan(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightCyan, text) -} - -func Magenta(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightMagenta, text) -} - -func White(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightWhite, text) -} - -func Black(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBrightBlack, text) +func Col(text string) string { return text } +func Yellow(text string) string { return tui.Yellow(text) } +func Red(text string) string { return tui.Red(text) } +func Blue(text string) string { return tui.Blue(text) } +func Green(text string) string { return tui.Green(text) } +func Cyan(text string) string { return tui.Cyan(text) } +func Magenta(text string) string { return tui.Magenta(text) } +func White(text string) string { return tui.White(text) } +func Black(text string) string { return tui.Black(text) } + +func DarkYellow(text string) string { return tui.DarkYellow(text) } +func DarkRed(text string) string { return tui.DarkRed(text) } +func DarkBlue(text string) string { return tui.DarkBlue(text) } +func DarkGreen(text string) string { return tui.Green(text) } +func DarkCyan(text string) string { return tui.DarkCyan(text) } +func DarkMagenta(text string) string { return tui.DarkMagenta(text) } +func DarkWhite(text string) string { return tui.DarkWhite(text) } +func DarkBlack(text string) string { return tui.DarkBlack(text) } + +var rainbowCols = []func(string) string{ + tui.Red, tui.Yellow, tui.Green, tui.Cyan, tui.Blue, tui.Magenta, } -func DarkYellow(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundYellow, text) -} - -func DarkRed(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundRed, text) -} - -func DarkBlue(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBlue, text) -} - -func DarkGreen(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundGreen, text) -} - -func DarkCyan(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundCyan, text) -} - -func DarkMagenta(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundMagenta, text) -} - -func DarkWhite(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundWhite, text) -} - -func DarkBlack(text string) string { - if !ColourEnabled { - return text - } - return Col(ctc.ForegroundBlack, text) -} - -var rainbowCols = []func(string) string{Red, Yellow, Green, Cyan, Blue, Magenta} - func Rainbow(text string) string { if !ColourEnabled { return text } var builder strings.Builder - for i := 0; i < len(text); i++ { fn := rainbowCols[i%len(rainbowCols)] builder.WriteString(fn(text[i : i+1])) } - return builder.String() } diff --git a/v2/internal/tui/tui.go b/v2/internal/tui/tui.go new file mode 100644 index 00000000000..65877c27daf --- /dev/null +++ b/v2/internal/tui/tui.go @@ -0,0 +1,317 @@ +// Package tui provides a unified terminal UI for the Wails CLI. +// It replaces the previous mix of pterm, wzshiming/ctc, and labstack/gommon/color +// with a single coherent system: glyph for interactive elements (spinners, progress) +// and direct ANSI codes for plain styled text. +package tui + +import ( + "fmt" + "os" + "strings" + "sync" + "time" + + "github.com/kungfusheep/glyph" +) + +// ColourEnabled controls whether ANSI colors and TUI effects are used. +// Set to false via -nocolor flag, NO_COLOR env var, or non-TTY stdout. +var ColourEnabled = true + +func init() { + if os.Getenv("NO_COLOR") != "" { + ColourEnabled = false + return + } + if os.Getenv("TERM") == "dumb" { + ColourEnabled = false + return + } + // Disable color when stdout is not a terminal (CI, pipes) + fi, err := os.Stdout.Stat() + if err == nil && (fi.Mode()&os.ModeCharDevice) == 0 { + ColourEnabled = false + } +} + +// SetNoColour disables all color and TUI output. +func SetNoColour() { + ColourEnabled = false +} + +// ansi returns ANSI-escaped text when colour is enabled, plain text otherwise. +func ansi(code, text string) string { + if !ColourEnabled { + return text + } + return "\033[" + code + "m" + text + "\033[0m" +} + +// Fatal prints a FATAL message to stderr and exits with code 1. +func Fatal(message string) { + fmt.Fprintln(os.Stderr, ansi("1;91", "FATAL")+" "+message) + os.Exit(1) +} + +// Error prints an error message. +func Error(message string) { + fmt.Println(ansi("91", " ✗")+" "+message) +} + +// Success prints a success message. +func Success(message string) { + fmt.Println(ansi("92", " ✓")+" "+message) +} + +// Info prints an informational message. +func Info(message string) { + fmt.Println(ansi("94", " →")+" "+message) +} + +// Warning prints a warning message. +func Warning(message string) { + fmt.Println(ansi("93", " !")+" "+message) +} + +// Println prints text followed by a newline. +func Println(text string) { + fmt.Println(text) +} + +// Printf prints formatted text. +func Printf(format string, args ...any) { + fmt.Printf(format, args...) +} + +// Section prints a styled section header. +func Section(title string) { + fmt.Println() + if ColourEnabled { + fmt.Println(ansi("1;94", title)) + fmt.Println(ansi("2", strings.Repeat("─", 40))) + } else { + fmt.Println("=== " + title + " ===") + } +} + +// BulletPoint prints a formatted bullet point. +func BulletPoint(text string, args ...any) { + msg := fmt.Sprintf(text, args...) + if ColourEnabled { + fmt.Println(" " + ansi("94", "•") + " " + msg) + } else { + fmt.Println(" - " + msg) + } +} + +// Table prints a two-column key-value table. +func Table(rows [][]string) { + if len(rows) == 0 { + return + } + maxKey := 0 + for _, row := range rows { + if len(row) > 0 && len(row[0]) > maxKey { + maxKey = len(row[0]) + } + } + for _, row := range rows { + if len(row) < 2 { + continue + } + key := row[0] + val := row[1] + if ColourEnabled { + fmt.Printf(" %s%s %s\n", + ansi("2", key), + strings.Repeat(" ", maxKey-len(key)), + val, + ) + } else { + fmt.Printf(" %-*s %s\n", maxKey, key, val) + } + } +} + +// HeaderTable prints a table with the first row as a bold header. +func HeaderTable(rows [][]string) { + if len(rows) == 0 { + return + } + // Calculate column widths + widths := make([]int, len(rows[0])) + for _, row := range rows { + for i, cell := range row { + if i < len(widths) && len(cell) > widths[i] { + widths[i] = len(cell) + } + } + } + for i, row := range rows { + line := " " + for j, cell := range row { + w := 0 + if j < len(widths) { + w = widths[j] + } + padded := cell + strings.Repeat(" ", w-len(cell)) + if i == 0 && ColourEnabled { + line += ansi("1", padded) + " " + } else { + line += padded + " " + } + } + fmt.Println(line) + if i == 0 { + sep := " " + for j := range row { + w := 0 + if j < len(widths) { + w = widths[j] + } + sep += strings.Repeat("-", w) + " " + } + fmt.Println(sep) + } + } +} + +// BoxedTable prints a section header followed by a table. +func BoxedTable(title string, rows [][]string) { + if title != "" { + Section(title) + } + Table(rows) +} + +// spinnerFrames are the braille spinner animation frames. +var spinnerFrames = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"} + +// WithSpinner runs fn while displaying an animated spinner. +// On completion, a success or failure indicator replaces the spinner. +// In non-TTY mode it prints a plain start/done message instead. +func WithSpinner(message string, fn func() error) error { + if !ColourEnabled { + fmt.Println(message + "...") + err := fn() + if err != nil { + fmt.Println(" Failed: " + err.Error()) + } else { + fmt.Println(" Done.") + } + return err + } + + var ( + done bool + runErr error + mu sync.Mutex + frame int + ) + + displayMsg := message + app := glyph.NewInlineApp() + app.Height(1) + app.SetView( + glyph.HBox( + glyph.Spinner(&frame).Frames(glyph.SpinnerBraille).FG(glyph.Cyan), + glyph.SpaceW(1), + glyph.Text(&displayMsg), + ), + ) + + go func() { + for { + mu.Lock() + d := done + mu.Unlock() + if d { + return + } + frame++ + app.RequestRender() + time.Sleep(80 * time.Millisecond) + } + }() + + go func() { + runErr = fn() + mu.Lock() + done = true + mu.Unlock() + app.Stop() + }() + + _ = app.RunNonInteractive() + + if runErr != nil { + fmt.Println(ansi("91", " ✗") + " " + message) + } else { + fmt.Println(ansi("92", " ✓") + " " + message) + } + return runErr +} + +// Green returns green-colored text when colour is enabled. +func Green(text string) string { return ansi("92", text) } + +// Red returns bright red text when colour is enabled. +func Red(text string) string { return ansi("91", text) } + +// DarkRed returns dark red text when colour is enabled. +func DarkRed(text string) string { return ansi("31", text) } + +// Yellow returns yellow text when colour is enabled. +func Yellow(text string) string { return ansi("93", text) } + +// DarkYellow returns dark yellow text when colour is enabled. +func DarkYellow(text string) string { return ansi("33", text) } + +// Blue returns blue text when colour is enabled. +func Blue(text string) string { return ansi("94", text) } + +// DarkBlue returns dark blue text when colour is enabled. +func DarkBlue(text string) string { return ansi("34", text) } + +// Cyan returns cyan text when colour is enabled. +func Cyan(text string) string { return ansi("96", text) } + +// DarkCyan returns dark cyan text when colour is enabled. +func DarkCyan(text string) string { return ansi("36", text) } + +// Magenta returns magenta text when colour is enabled. +func Magenta(text string) string { return ansi("95", text) } + +// DarkMagenta returns dark magenta text when colour is enabled. +func DarkMagenta(text string) string { return ansi("35", text) } + +// White returns bright white text when colour is enabled. +func White(text string) string { return ansi("97", text) } + +// DarkWhite returns regular white text when colour is enabled. +func DarkWhite(text string) string { return ansi("37", text) } + +// Black returns bright black (dark grey) text when colour is enabled. +func Black(text string) string { return ansi("90", text) } + +// DarkBlack returns black text when colour is enabled. +func DarkBlack(text string) string { return ansi("30", text) } + +// Gray returns grey text when colour is enabled. +func Gray(text string) string { return ansi("2", text) } + +// Bold returns bold text when colour is enabled. +func Bold(text string) string { return ansi("1", text) } + +// Rainbow returns text with cycling colors when colour is enabled. +func Rainbow(text string) string { + if !ColourEnabled { + return text + } + codes := []string{"91", "93", "92", "96", "94", "95"} + var sb strings.Builder + for i, ch := range text { + sb.WriteString(ansi(codes[i%len(codes)], string(ch))) + } + return sb.String() +} diff --git a/v2/pkg/clilogger/clilogger.go b/v2/pkg/clilogger/clilogger.go index 50eb46fdfc0..a2fdf7cc06b 100644 --- a/v2/pkg/clilogger/clilogger.go +++ b/v2/pkg/clilogger/clilogger.go @@ -5,7 +5,7 @@ import ( "io" "os" - "github.com/wailsapp/wails/v2/internal/colour" + "github.com/wailsapp/wails/v2/internal/tui" ) // CLILogger is used by the cli @@ -34,7 +34,7 @@ func (c *CLILogger) Print(message string, args ...interface{}) { _, err := fmt.Fprintf(c.Writer, message, args...) if err != nil { - c.Fatal("%s", "FATAL: " + err.Error()) + c.Fatal("%s", "FATAL: "+err.Error()) } } @@ -46,16 +46,16 @@ func (c *CLILogger) Println(message string, args ...interface{}) { temp := fmt.Sprintf(message, args...) _, err := fmt.Fprintln(c.Writer, temp) if err != nil { - c.Fatal("%s", "FATAL: " + err.Error()) + c.Fatal("%s", "FATAL: "+err.Error()) } } // Fatal prints the given message then aborts func (c *CLILogger) Fatal(message string, args ...interface{}) { temp := fmt.Sprintf(message, args...) - _, err := fmt.Fprintln(c.Writer, colour.Red("FATAL: "+temp)) + _, err := fmt.Fprintln(c.Writer, tui.Red("FATAL: "+temp)) if err != nil { - println(colour.Red("FATAL: " + err.Error())) + println(tui.Red("FATAL: " + err.Error())) } os.Exit(1) }