5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 15:30:37 +08:00

Big banner for Setup/Help. Small banner for commands.

This commit is contained in:
Lea Anthony 2019-02-22 08:44:30 +11:00
parent 2dad29673d
commit 753c5fd337
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
9 changed files with 25 additions and 20 deletions

View File

@ -21,7 +21,7 @@ func (app *App) setupCli() *cmd.Cli {
// Banner // Banner
result.PreRun(func(cli *cmd.Cli) error { result.PreRun(func(cli *cmd.Cli) error {
log := cmd.NewLogger() log := cmd.NewLogger()
log.PrintBanner() log.PrintSmallBanner()
fmt.Println() fmt.Println()
log.YellowUnderline(app.config.Title + " - Debug Build") log.YellowUnderline(app.config.Title + " - Debug Build")
return nil return nil

View File

@ -194,6 +194,7 @@ func (c *Command) Action(callback Action) *Command {
// PrintHelp - Output the help text for this command // PrintHelp - Output the help text for this command
func (c *Command) PrintHelp() { func (c *Command) PrintHelp() {
c.log.PrintBanner()
versionString := c.AppVersion versionString := c.AppVersion
if versionString != "" { if versionString != "" {
versionString = " " + versionString versionString = " " + versionString
@ -211,7 +212,6 @@ func (c *Command) PrintHelp() {
fmt.Println(c.Longdescription + "\n") fmt.Println(c.Longdescription + "\n")
} }
if len(c.SubCommands) > 0 { if len(c.SubCommands) > 0 {
fmt.Println("")
c.log.White("Available commands:") c.log.White("Available commands:")
fmt.Println("") fmt.Println("")
for _, subcommand := range c.SubCommands { 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.Printf(" %s%s%s %s\n", subcommand.Name, spacer, subcommand.Shortdescription, isDefault)
} }
fmt.Println("")
} }
if c.flagCount > 0 { if c.flagCount > 0 {
fmt.Println("")
c.log.White("Flags:") c.log.White("Flags:")
fmt.Println() fmt.Println()
c.Flags.SetOutput(os.Stdout) c.Flags.SetOutput(os.Stdout)

View File

@ -99,6 +99,16 @@ func (l *Logger) Error(format string, a ...interface{}) {
color.New(color.FgHiRed).PrintfFunc()("Error: "+format+"\n", a...) 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 // PrintBanner prints the Wails banner before running commands
func (l *Logger) PrintBanner() error { func (l *Logger) PrintBanner() error {
banner1 := ` _ __ _ __ banner1 := ` _ __ _ __

View File

@ -2,4 +2,4 @@ package cmd
// Version - Wails version // Version - Wails version
// ...oO(There must be a better way) // ...oO(There must be a better way)
const Version = "v0.9.1" const Version = "v0.9.2"

View File

@ -18,6 +18,8 @@ func init() {
setupCommand.Action(func() error { setupCommand.Action(func() error {
logger.PrintBanner();
system := cmd.NewSystemHelper() system := cmd.NewSystemHelper()
err := system.Initialise() err := system.Initialise()
if err != nil { if err != nil {

View File

@ -24,7 +24,7 @@ Any flags that are required and not given will be prompted for.`
initCommand.Action(func() error { initCommand.Action(func() error {
logger.WhiteUnderline("Initialising project") logger.PrintSmallBanner("Initialising project")
fmt.Println() fmt.Println()
// Check if the system is initialised // Check if the system is initialised

View File

@ -25,12 +25,12 @@ func init() {
initCmd.Action(func() error { initCmd.Action(func() error {
log := cmd.NewLogger()
message := "Building Application" message := "Building Application"
if forceRebuild { if forceRebuild {
message += " (force rebuild)" message += " (force rebuild)"
} }
log.WhiteUnderline(message) logger.PrintSmallBanner(message)
fmt.Println()
// Project options // Project options
projectOptions := &cmd.ProjectOptions{} projectOptions := &cmd.ProjectOptions{}

View File

@ -1,6 +1,8 @@
package main package main
import ( import (
"fmt"
"github.com/leaanthony/spinner" "github.com/leaanthony/spinner"
"github.com/wailsapp/wails/cmd" "github.com/wailsapp/wails/cmd"
) )
@ -17,12 +19,10 @@ func init() {
BoolFlag("f", "Force rebuild of application components", &forceRebuild) BoolFlag("f", "Force rebuild of application components", &forceRebuild)
initCmd.Action(func() error { initCmd.Action(func() error {
log := cmd.NewLogger()
message := "Building Application" message := "Serving Application"
if forceRebuild { logger.PrintSmallBanner(message)
message += " (force rebuild)" fmt.Println()
}
log.WhiteUnderline(message)
// Project options // Project options
projectOptions := &cmd.ProjectOptions{} projectOptions := &cmd.ProjectOptions{}

View File

@ -10,15 +10,8 @@ var logger = cmd.NewLogger()
// Create main app // Create main app
var app = cmd.NewCli("wails", "A cli tool for building Wails applications.") 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! // Main!
func main() { func main() {
app.PreRun(printBanner)
err := app.Run() err := app.Run()
if err != nil { if err != nil {
logger.Error(err.Error()) logger.Error(err.Error())