Add docs and sponsor subcommands

This commit is contained in:
Lea Anthony 2024-06-24 20:50:17 +10:00
commit 25cccc32db
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405

View file

@ -1,6 +1,7 @@
package main
import (
"github.com/pkg/browser"
"os"
"runtime/debug"
@ -28,6 +29,7 @@ func init() {
func main() {
app := clir.NewCli("wails", "The Wails3 CLI", "v3")
app.NewSubCommand("docs", "Open the docs").Action(openDocs)
app.NewSubCommandFunction("init", "Initialise a new project", commands.Init)
app.NewSubCommandFunction("build", "Build the project", commands.Build)
app.NewSubCommandFunction("dev", "Run in Dev mode", commands.Dev)
@ -65,6 +67,8 @@ func main() {
tool.NewSubCommandFunction("cp", "Copy files", commands.Cp)
app.NewSubCommandFunction("version", "Print the version", commands.Version)
app.NewSubCommand("sponsor", "Sponsor the project").Action(openSponsor)
defer printFooter()
err := app.Run()
if err != nil {
@ -72,3 +76,25 @@ func main() {
os.Exit(1)
}
}
func printFooter() {
pterm.Println(pterm.LightGreen("\nDon't know what to do next? Run: ") + pterm.LightYellow("wails3 docs\n"))
// Check if we're in a teminal
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.LightYellow("wails3 sponsor"))
}
func openDocs() error {
return browser.OpenURL("https://v3alpha.wails.io/getting-started/your-first-app/")
}
func openSponsor() error {
return browser.OpenURL("https://github.com/sponsors/leaanthony")
}