diff --git a/README.md b/README.md index 12d9edc9..b6970056 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmd/init.go b/cmd/init.go index 555111b6..cd76fc69 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -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) {