mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 05:11:29 +08:00
feature/turn off color terminal output of dev command (#1947)
* feat: Adds option to dev command to turn off color terminal output * Update docs Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
parent
8b07a0f582
commit
7fcb537f85
@ -93,6 +93,7 @@ type devFlags struct {
|
||||
|
||||
frontendDevServerURL string
|
||||
skipFrontend bool
|
||||
noColour bool
|
||||
}
|
||||
|
||||
// AddSubcommand adds the `dev` command for the Wails application
|
||||
@ -108,6 +109,7 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
command.StringFlag("reloaddirs", "Additional directories to trigger reloads (comma separated)", &flags.reloadDirs)
|
||||
command.BoolFlag("browser", "Open application in browser", &flags.openBrowser)
|
||||
command.BoolFlag("noreload", "Disable reload on asset change", &flags.noReload)
|
||||
command.BoolFlag("nocolour", "Turn off colour cli output", &flags.noColour)
|
||||
command.BoolFlag("skipbindings", "Skip bindings generation", &flags.skipBindings)
|
||||
command.StringFlag("wailsjsdir", "Directory to generate the Wails JS modules", &flags.wailsjsdir)
|
||||
command.StringFlag("tags", "Build tags to pass to Go compiler. Must be quoted. Space or comma (but not both) separated", &flags.tags)
|
||||
@ -123,6 +125,10 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
|
||||
command.BoolFlag("s", "Skips building the frontend", &flags.skipFrontend)
|
||||
|
||||
command.Action(func() error {
|
||||
if flags.noColour {
|
||||
colour.ColourEnabled = false
|
||||
}
|
||||
|
||||
// Create logger
|
||||
logger := clilogger.New(w)
|
||||
app.PrintBanner()
|
||||
|
@ -7,77 +7,133 @@ import (
|
||||
"github.com/wzshiming/ctc"
|
||||
)
|
||||
|
||||
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 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++ {
|
||||
|
@ -167,7 +167,7 @@ Your system is ready for Wails development!
|
||||
- On macOS, it will bundle the application into a `.app` file and run it. It will use a `build/darwin/Info.dev.plist` for development.
|
||||
|
||||
| Flag | Description | Default |
|
||||
| :--------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
|
||||
|:-----------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------|
|
||||
| -assetdir "./path/to/assets" | Serve assets from the given directory instead of using the provided asset FS | Value in `wails.json` |
|
||||
| -browser | Opens a browser to `http://localhost:34115` on startup | |
|
||||
| -compiler "compiler" | Use a different go compiler to build, eg go1.15beta1 | go |
|
||||
@ -177,6 +177,7 @@ Your system is ready for Wails development!
|
||||
| -tags "extra tags" | Build tags to pass to compiler (quoted and space separated) | |
|
||||
| -loglevel "loglevel" | Loglevel to use - Trace, Debug, Info, Warning, Error | Debug |
|
||||
| -noreload | Disable automatic reload when assets change | |
|
||||
| -nocolour | Turn off colour cli output | false |
|
||||
| -nogen | Disable generate module | |
|
||||
| -v | Verbosity level (0 - silent, 1 - standard, 2 - verbose) | 1 |
|
||||
| -wailsjsdir | The directory to generate the generated Wails JS modules | Value in `wails.json` |
|
||||
|
Loading…
Reference in New Issue
Block a user