mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 06:01:48 +08:00
Big banner for Setup/Help. Small banner for commands.
This commit is contained in:
parent
2dad29673d
commit
753c5fd337
@ -21,7 +21,7 @@ func (app *App) setupCli() *cmd.Cli {
|
||||
// Banner
|
||||
result.PreRun(func(cli *cmd.Cli) error {
|
||||
log := cmd.NewLogger()
|
||||
log.PrintBanner()
|
||||
log.PrintSmallBanner()
|
||||
fmt.Println()
|
||||
log.YellowUnderline(app.config.Title + " - Debug Build")
|
||||
return nil
|
||||
|
@ -194,6 +194,7 @@ func (c *Command) Action(callback Action) *Command {
|
||||
|
||||
// PrintHelp - Output the help text for this command
|
||||
func (c *Command) PrintHelp() {
|
||||
c.log.PrintBanner()
|
||||
versionString := c.AppVersion
|
||||
if versionString != "" {
|
||||
versionString = " " + versionString
|
||||
@ -211,7 +212,6 @@ func (c *Command) PrintHelp() {
|
||||
fmt.Println(c.Longdescription + "\n")
|
||||
}
|
||||
if len(c.SubCommands) > 0 {
|
||||
fmt.Println("")
|
||||
c.log.White("Available commands:")
|
||||
fmt.Println("")
|
||||
for _, subcommand := range c.SubCommands {
|
||||
@ -222,9 +222,9 @@ func (c *Command) PrintHelp() {
|
||||
}
|
||||
fmt.Printf(" %s%s%s %s\n", subcommand.Name, spacer, subcommand.Shortdescription, isDefault)
|
||||
}
|
||||
fmt.Println("")
|
||||
}
|
||||
if c.flagCount > 0 {
|
||||
fmt.Println("")
|
||||
c.log.White("Flags:")
|
||||
fmt.Println()
|
||||
c.Flags.SetOutput(os.Stdout)
|
||||
|
10
cmd/log.go
10
cmd/log.go
@ -99,6 +99,16 @@ func (l *Logger) Error(format string, a ...interface{}) {
|
||||
color.New(color.FgHiRed).PrintfFunc()("Error: "+format+"\n", a...)
|
||||
}
|
||||
|
||||
func (l *Logger) PrintSmallBanner(message ...string) {
|
||||
yellow := color.New(color.FgYellow).SprintFunc()
|
||||
red := color.New(color.FgRed).SprintFunc()
|
||||
msg := ""
|
||||
if len(message) > 0 {
|
||||
msg = " - " + message[0]
|
||||
}
|
||||
fmt.Printf("%s %s%s\n", yellow("Wails"), red(Version), msg)
|
||||
}
|
||||
|
||||
// PrintBanner prints the Wails banner before running commands
|
||||
func (l *Logger) PrintBanner() error {
|
||||
banner1 := ` _ __ _ __
|
||||
|
@ -2,4 +2,4 @@ package cmd
|
||||
|
||||
// Version - Wails version
|
||||
// ...oO(There must be a better way)
|
||||
const Version = "v0.9.1"
|
||||
const Version = "v0.9.2"
|
||||
|
@ -18,6 +18,8 @@ func init() {
|
||||
|
||||
setupCommand.Action(func() error {
|
||||
|
||||
logger.PrintBanner();
|
||||
|
||||
system := cmd.NewSystemHelper()
|
||||
err := system.Initialise()
|
||||
if err != nil {
|
||||
|
@ -24,7 +24,7 @@ Any flags that are required and not given will be prompted for.`
|
||||
|
||||
initCommand.Action(func() error {
|
||||
|
||||
logger.WhiteUnderline("Initialising project")
|
||||
logger.PrintSmallBanner("Initialising project")
|
||||
fmt.Println()
|
||||
|
||||
// Check if the system is initialised
|
||||
|
@ -25,12 +25,12 @@ func init() {
|
||||
|
||||
initCmd.Action(func() error {
|
||||
|
||||
log := cmd.NewLogger()
|
||||
message := "Building Application"
|
||||
if forceRebuild {
|
||||
message += " (force rebuild)"
|
||||
}
|
||||
log.WhiteUnderline(message)
|
||||
logger.PrintSmallBanner(message)
|
||||
fmt.Println()
|
||||
|
||||
// Project options
|
||||
projectOptions := &cmd.ProjectOptions{}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/leaanthony/spinner"
|
||||
"github.com/wailsapp/wails/cmd"
|
||||
)
|
||||
@ -17,12 +19,10 @@ func init() {
|
||||
BoolFlag("f", "Force rebuild of application components", &forceRebuild)
|
||||
|
||||
initCmd.Action(func() error {
|
||||
log := cmd.NewLogger()
|
||||
message := "Building Application"
|
||||
if forceRebuild {
|
||||
message += " (force rebuild)"
|
||||
}
|
||||
log.WhiteUnderline(message)
|
||||
|
||||
message := "Serving Application"
|
||||
logger.PrintSmallBanner(message)
|
||||
fmt.Println()
|
||||
|
||||
// Project options
|
||||
projectOptions := &cmd.ProjectOptions{}
|
||||
|
@ -10,15 +10,8 @@ var logger = cmd.NewLogger()
|
||||
// Create main app
|
||||
var app = cmd.NewCli("wails", "A cli tool for building Wails applications.")
|
||||
|
||||
// Prints the cli banner
|
||||
func printBanner(app *cmd.Cli) error {
|
||||
logger.PrintBanner()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Main!
|
||||
func main() {
|
||||
app.PreRun(printBanner)
|
||||
err := app.Run()
|
||||
if err != nil {
|
||||
logger.Error(err.Error())
|
||||
|
Loading…
Reference in New Issue
Block a user