diff --git a/cmd/project.go b/cmd/project.go index c71b3d135..478855c4c 100644 --- a/cmd/project.go +++ b/cmd/project.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "os" "path/filepath" "runtime" "strings" @@ -190,7 +191,7 @@ func (po *ProjectOptions) PromptForInputs() error { po.NPMProjectName = strings.ToLower(strings.Replace(po.Name, " ", "_", -1)) // Fix template name - po.Template = strings.Split(po.selectedTemplate.Path, "/")[0] + po.Template = strings.Split(po.selectedTemplate.Path, string(os.PathSeparator))[0] // // Populate template details templateMetadata := po.selectedTemplate.Metadata diff --git a/cmd/prompt.go b/cmd/prompt.go index db55a57d1..13f34afe8 100644 --- a/cmd/prompt.go +++ b/cmd/prompt.go @@ -1,25 +1,26 @@ package cmd import ( + "bufio" "fmt" + "os" "strconv" ) // Prompt asks the user for a value func Prompt(question string, defaultValue ...string) string { var answer string - haveDefault := len(defaultValue) > 0 && defaultValue[0] != "" - if haveDefault { - question = fmt.Sprintf("%s (%s)", question, defaultValue[0]) + if len(defaultValue) > 0 { + answer = defaultValue[0] + question = fmt.Sprintf("%s (%s)", question, answer) } fmt.Printf(question + ": ") - fmt.Scanln(&answer) - if haveDefault { - if len(answer) == 0 { - answer = defaultValue[0] - } + scanner := bufio.NewScanner(os.Stdin) + if scanner.Scan() { + answer = scanner.Text() } + return answer } diff --git a/cmd/version.go b/cmd/version.go index d43280140..c4638d753 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -2,4 +2,4 @@ package cmd // Version - Wails version // ...oO(There must be a better way) -const Version = "v0.9.6" +const Version = "v0.9.7" diff --git a/cmd/wails/9_issue.go b/cmd/wails/9_issue.go new file mode 100644 index 000000000..6be68199c --- /dev/null +++ b/cmd/wails/9_issue.go @@ -0,0 +1,74 @@ +package main + +import ( + "fmt" + "io/ioutil" + "net/http" + "net/url" + "os" + "runtime" + "strings" + + "github.com/pkg/browser" + + "github.com/wailsapp/wails/cmd" +) + +func init() { + + commandDescription := `Generates an issue in Github using the given title, description and system report.` + + initCommand := app.Command("issue", "Generates an issue in Github."). + LongDescription(commandDescription) + + initCommand.Action(func() error { + + logger.PrintSmallBanner("Generate Issue") + fmt.Println() + message := `Thanks for taking the time to submit an issue! + +To help you in this process, we will ask for some information, add Go/Wails details automatically, then prepare the issue for your editing and submission. +` + + logger.Yellow(message) + + title := cmd.Prompt("Issue Title") + description := cmd.Prompt("Issue Description") + + var str strings.Builder + + gomodule, exists := os.LookupEnv("GO111MODULE") + if !exists { + gomodule = "(Not Set)" + } + + str.WriteString("\n| Name | Value |\n| ----- | ----- |\n") + str.WriteString(fmt.Sprintf("| Wails Version | %s |\n", cmd.Version)) + str.WriteString(fmt.Sprintf("| Go Version | %s |\n", runtime.Version())) + str.WriteString(fmt.Sprintf("| Platform | %s |\n", runtime.GOOS)) + str.WriteString(fmt.Sprintf("| Arch | %s |\n", runtime.GOARCH)) + str.WriteString(fmt.Sprintf("| GO111MODULE | %s |\n", gomodule)) + + fmt.Println() + fmt.Println("Processing template and preparing for upload.") + + // Grab issue template + resp, err := http.Get("https://raw.githubusercontent.com/wailsapp/wails/master/.github/ISSUE_TEMPLATE/bug_report.md") + if err != nil { + logger.Red("Unable to read in issue template. Are you online?") + os.Exit(1) + } + defer resp.Body.Close() + template, _ := ioutil.ReadAll(resp.Body) + body := string(template) + body = "**Description**\n" + (strings.Split(body, "**Description**")[1]) + fullURL := "https://github.com/wailsapp/wails/issues/new?" + body = strings.Replace(body, "A clear and concise description of what the bug is.", description, -1) + body = strings.Replace(body, "Please paste the output of `wails report` here.", str.String(), -1) + params := "title=" + title + "&body=" + body + + fmt.Println("Opening browser to file issue.") + browser.OpenURL(fullURL + url.PathEscape(params)) + return nil + }) +} diff --git a/go.mod b/go.mod index fc7e466f6..b55b9139a 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/openzipkin/zipkin-go v0.1.5 // indirect + github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 github.com/pkg/errors v0.8.1 // indirect github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90 // indirect github.com/prometheus/common v0.2.0 // indirect diff --git a/go.sum b/go.sum index a5e7d1ae0..65e00e780 100644 --- a/go.sum +++ b/go.sum @@ -138,6 +138,8 @@ github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTm github.com/openzipkin/zipkin-go v0.1.3/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= github.com/openzipkin/zipkin-go v0.1.5/go.mod h1:8NDCjKHoHW1XOp/vf3lClHem0b91r4433B67KXyKXAQ= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=