From 9a17dd53f24e700450a5b208c06e7c8151b809a6 Mon Sep 17 00:00:00 2001 From: Drakirus Date: Wed, 11 Sep 2019 12:54:32 +0200 Subject: [PATCH 1/3] feat: don't require a arg when hover init --- cmd/init.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/init.go b/cmd/init.go index 555111b6..069b36b8 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -1,11 +1,11 @@ package cmd import ( - "errors" "fmt" "io" "os" "os/exec" + "os/user" "path/filepath" "github.com/spf13/cobra" @@ -18,14 +18,19 @@ func init() { var initCmd = &cobra.Command{ Use: "init [project]", Short: "Initialize a flutter project to use go-flutter", - Args: func(cmd *cobra.Command, args []string) error { - if len(args) != 1 { - return errors.New("requires one argument, the project path. e.g.: github.com/my-organization/my-app") - } - return nil - }, Run: func(cmd *cobra.Command, args []string) { - projectPath := args[0] + var projectPath string + if len(args) == 0 || args[0] == "." { + projectName := getPubSpec().Name + u, err := user.Current() + if err != nil { + fmt.Printf("hover: Couldn't get current user: %v\n", err) + } + projectPath = "github.com/" + u.Username + "/" + projectName + } else { + projectPath = args[0] + } + assertInFlutterProject() err := os.Mkdir(buildPath, 0775) From 6c34538fbb91c028e6234d70b9e46421eab758de Mon Sep 17 00:00:00 2001 From: Drakirus Date: Wed, 11 Sep 2019 12:56:50 +0200 Subject: [PATCH 2/3] update rdm --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 12d9edc9..3932c1df 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,8 @@ cd into a flutter project. cd projects/simpleApplication ``` -The first time you use hover for a project, you'll need to initialize the project for desktop. `hover init` requires a project path. This is usualy the path for your project on github or a self-hosted git service. _If you are unsure, just make something up, it can always be changed later._ - ```bash -hover init github.com/my-organization/simpleApplication +hover init ``` This creates the directory `go` and adds boilerplate files such as Go code and a default logo. From 3a1d7c6e4df49305525d677ec3106ea84167b79c Mon Sep 17 00:00:00 2001 From: Drakirus Date: Thu, 12 Sep 2019 20:58:39 +0200 Subject: [PATCH 3/3] resolve review comments --- README.md | 4 +++- cmd/init.go | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3932c1df..b6970056 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,10 @@ cd into a flutter project. cd projects/simpleApplication ``` +The first time you use hover for a project, you'll need to initialize the project for desktop. An argument can be passed to `hover init` to set the project path. This is usually the path for your project on github or a self-hosted git service. _If you are unsure, use `hover init`, the generated path can always be changed later._ + ```bash -hover init +hover init github.com/my-organization/simpleApplication ``` This creates the directory `go` and adds boilerplate files such as Go code and a default logo. diff --git a/cmd/init.go b/cmd/init.go index 069b36b8..cd76fc69 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -1,11 +1,11 @@ package cmd import ( + "errors" "fmt" "io" "os" "os/exec" - "os/user" "path/filepath" "github.com/spf13/cobra" @@ -18,21 +18,22 @@ func init() { var initCmd = &cobra.Command{ Use: "init [project]", Short: "Initialize a flutter project to use go-flutter", + Args: func(cmd *cobra.Command, args []string) error { + if len(args) > 1 { + return errors.New("allows only one argument, the project path. e.g.: github.com/my-organization/my-app") + } + return nil + }, Run: func(cmd *cobra.Command, args []string) { + assertInFlutterProject() + var projectPath string if len(args) == 0 || args[0] == "." { - projectName := getPubSpec().Name - u, err := user.Current() - if err != nil { - fmt.Printf("hover: Couldn't get current user: %v\n", err) - } - projectPath = "github.com/" + u.Username + "/" + projectName + projectPath = getPubSpec().Name } else { projectPath = args[0] } - assertInFlutterProject() - err := os.Mkdir(buildPath, 0775) if err != nil { if os.IsExist(err) {