From 9fa153a38251ed8a5ee4e1d413a553e3128adc8f Mon Sep 17 00:00:00 2001 From: Wes Date: Tue, 7 Jan 2025 14:45:42 -0700 Subject: [PATCH] add getting started messages to ftl init --- .../docs/getting-started/quick-start/index.md | 6 ++---- frontend/cli/cmd_init.go | 20 +++++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/content/docs/getting-started/quick-start/index.md b/docs/content/docs/getting-started/quick-start/index.md index a396ff49e..eb5147975 100644 --- a/docs/content/docs/getting-started/quick-start/index.md +++ b/docs/content/docs/getting-started/quick-start/index.md @@ -67,13 +67,11 @@ The [FTL VSCode extension](https://marketplace.visualstudio.com/items?itemName=F Once FTL is installed, initialize an FTL project: ``` -mkdir myproject +ftl init myproject cd myproject -ftl init myproject . ``` -This will create an `ftl-project.toml` file, a git repository, and a `bin/` directory with Hermit tooling. The Hermit tooling -includes the current version of FTL, and language support for go and JVM based languages. +This will create a new `myproject` directory containing an `ftl-project.toml` file, a git repository, and a `bin/` directory with Hermit tooling. The Hermit tooling includes the current version of FTL, and language support for go and JVM based languages. ### Create a new module diff --git a/frontend/cli/cmd_init.go b/frontend/cli/cmd_init.go index 8ed026c3d..165d7f3c9 100644 --- a/frontend/cli/cmd_init.go +++ b/frontend/cli/cmd_init.go @@ -28,7 +28,7 @@ var userHermitPackages string type initCmd struct { Name string `arg:"" help:"Name of the project."` - Dir string `arg:"" optional:"" help:"Directory to initialize the project in. If not specified, creates a new directory with the project name." default:"."` + Dir string `arg:"" optional:"" help:"Directory to initialize the project in. If not specified, creates a new directory with the project name."` Hermit bool `help:"Include Hermit language-specific toolchain binaries." negatable:"" default:"true"` ModuleDirs []string `help:"Child directories of existing modules."` ModuleRoots []string `help:"Root directories of existing modules."` @@ -39,9 +39,9 @@ type initCmd struct { func (i initCmd) Help() string { return ` Examples: - ftl init my-app # Creates a new folder named "my-app" and initializes it - ftl init my-app . # Initializes the current directory as "my-app" - ftl init my-app custom # Creates a folder named "custom" and initializes it as "my-app"` + ftl init myproject # Creates a new folder named "myproject" and initializes it + ftl init myproject . # Initializes the current directory as "myproject" + ftl init myproject custom # Creates a folder named "custom" and initializes it as "myproject"` } func (i initCmd) Run( @@ -50,12 +50,13 @@ func (i initCmd) Run( configRegistry *providers.Registry[configuration.Configuration], secretsRegistry *providers.Registry[configuration.Secrets], ) error { - if i.Dir == "." && !strings.Contains(i.Name, "/") { + // If the directory is not specified, use the project name as the directory name. + if i.Dir == "" { i.Dir = i.Name } logger.Debugf("Initializing FTL project in %s", i.Dir) - if err := os.MkdirAll(i.Dir, 0755); err != nil { + if err := os.MkdirAll(i.Dir, 0750); err != nil { return fmt.Errorf("failed to create directory: %w", err) } @@ -117,6 +118,13 @@ func (i initCmd) Run( } } } + + fmt.Printf("Successfully created FTL project '%s' in %s\n\n", i.Name, i.Dir) + fmt.Printf("To get started:\n") + if i.Dir != "." { + fmt.Printf(" cd %s\n", i.Dir) + } + fmt.Printf(" ftl dev\n") return nil }