Skip to content

Commit

Permalink
add getting started messages to ftl init
Browse files Browse the repository at this point in the history
  • Loading branch information
wesbillman committed Jan 7, 2025
1 parent c3dbe93 commit 9fa153a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 2 additions & 4 deletions docs/content/docs/getting-started/quick-start/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
20 changes: 14 additions & 6 deletions frontend/cli/cmd_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
Expand All @@ -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(
Expand All @@ -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)
}

Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 9fa153a

Please sign in to comment.