Skip to content

feat: don't require a arg when hover init #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ 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._
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 github.com/my-organization/simpleApplication
Expand Down
12 changes: 9 additions & 3 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ 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")
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) {
projectPath := args[0]
assertInFlutterProject()

var projectPath string
if len(args) == 0 || args[0] == "." {
projectPath = getPubSpec().Name
} else {
projectPath = args[0]
}

err := os.Mkdir(buildPath, 0775)
if err != nil {
if os.IsExist(err) {
Expand Down