Skip to content

Commit ccbdbac

Browse files
committed
resolve review comments
1 parent 6c34538 commit ccbdbac

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ cd into a flutter project.
4444
cd projects/simpleApplication
4545
```
4646

47+
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 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._
48+
4749
```bash
48-
hover init
50+
hover init github.com/my-organization/simpleApplication
4951
```
5052

5153
This creates the directory `go` and adds boilerplate files such as Go code and a default logo.

cmd/init.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package cmd
22

33
import (
4+
"errors"
45
"fmt"
56
"io"
67
"os"
78
"os/exec"
8-
"os/user"
99
"path/filepath"
1010

1111
"github.com/spf13/cobra"
@@ -18,21 +18,22 @@ func init() {
1818
var initCmd = &cobra.Command{
1919
Use: "init [project]",
2020
Short: "Initialize a flutter project to use go-flutter",
21+
Args: func(cmd *cobra.Command, args []string) error {
22+
if len(args) > 1 {
23+
return errors.New("allows only one argument, the project path. e.g.: github.com/my-organization/my-app")
24+
}
25+
return nil
26+
},
2127
Run: func(cmd *cobra.Command, args []string) {
28+
assertInFlutterProject()
29+
2230
var projectPath string
2331
if len(args) == 0 || args[0] == "." {
24-
projectName := getPubSpec().Name
25-
u, err := user.Current()
26-
if err != nil {
27-
fmt.Printf("hover: Couldn't get current user: %v\n", err)
28-
}
29-
projectPath = "github.com/" + u.Username + "/" + projectName
32+
projectPath = getPubSpec().Name
3033
} else {
3134
projectPath = args[0]
3235
}
3336

34-
assertInFlutterProject()
35-
3637
err := os.Mkdir(buildPath, 0775)
3738
if err != nil {
3839
if os.IsExist(err) {

0 commit comments

Comments
 (0)