From 7d171b0907e154b1cf6b966d0f0c07e7abedd297 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Mon, 24 Jun 2019 09:11:06 +1000 Subject: [PATCH] feat: initial support for platform requests --- cmd/linux.go | 28 ++++++++++++++++++++++++++++ cmd/system.go | 2 +- cmd/wails/0_setup.go | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cmd/linux.go b/cmd/linux.go index 781c3429..8186e7b2 100644 --- a/cmd/linux.go +++ b/cmd/linux.go @@ -3,9 +3,12 @@ package cmd import ( "fmt" "io/ioutil" + "net/url" "os" "regexp" "strings" + + "github.com/pkg/browser" ) // LinuxDistribution is of type int @@ -124,3 +127,28 @@ func RpmInstalled(packageName string) (bool, error) { _, _, exitCode, _ := rpm.Run("--query", packageName) return exitCode == 0, nil } + +// RequestSupportForDistribution promts the user to submit a request to support their +// currently unsupported distribution +func RequestSupportForDistribution(distroInfo *DistroInfo, libraryName string) error { + var logger = NewLogger() + defaultError := fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, libraryName) + + logger.Yellow("Distribution '%s' is not currently supported, but we would love to!", distroInfo.DistributorID) + q := fmt.Sprintf("Would you like to submit a request to support distribution '%s'?", distroInfo.DistributorID) + result := Prompt(q, "yes") + if strings.ToLower(result) != "yes" { + return defaultError + } + + title := fmt.Sprintf("Support Distribution '%s'", distroInfo.DistributorID) + + body := fmt.Sprintf("**Description**\nDistribution '%s' is curently unsupported.\n\n**Further Information**\n\n**Please add any extra information here, EG: libraries that are needed to make the distribution work, or commands to install them", distroInfo.DistributorID) + fullURL := "https://github.com/wailsapp/wails/issues/new?" + params := "title=" + title + "&body=" + body + + fmt.Println("Opening browser to file request.") + browser.OpenURL(fullURL + url.PathEscape(params)) + return nil + +} diff --git a/cmd/system.go b/cmd/system.go index af28058f..3f41f345 100644 --- a/cmd/system.go +++ b/cmd/system.go @@ -307,7 +307,7 @@ func CheckDependencies(logger *Logger) (bool, error) { logger.Green("Library '%s' installed.", library.Name) } default: - return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name) + return false, RequestSupportForDistribution(distroInfo, library.Name) } } } diff --git a/cmd/wails/0_setup.go b/cmd/wails/0_setup.go index 0149f6cd..b8413736 100644 --- a/cmd/wails/0_setup.go +++ b/cmd/wails/0_setup.go @@ -108,7 +108,7 @@ func checkLibraries() (errors bool, err error) { logger.Green("Library '%s' installed.", library.Name) } default: - return false, fmt.Errorf("unable to check libraries on distribution '%s'. Please ensure that the '%s' equivalent is installed", distroInfo.DistributorID, library.Name) + return false, cmd.RequestSupportForDistribution(distroInfo, library.Name) } } }