Skip to content
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
51 changes: 51 additions & 0 deletions docs/nav/learn/cli/init.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Init

Scaffold a new dotflow project interactively.

```bash
dotflow init
```

The command prompts for project configuration:

```
project_name [my-pipeline]: my-etl
storage [default]: s3
```

Output:

```
my-etl/
├── my_etl/
│ ├── __init__.py
│ ├── actions.py
│ └── workflow.py
├── tests/
│ └── test_workflow.py
├── pyproject.toml
└── README.md
```

## Storage options

| Option | Description |
|--------|-------------|
| `default` | In-memory, no persistence |
| `file` | Local disk (StorageFile) |
| `s3` | AWS S3 (StorageS3) — adds `dotflow[aws]` dependency |
| `gcs` | Google Cloud Storage (StorageGCS) — adds `dotflow[gcp]` dependency |

## Running the generated project

```bash
cd my-etl
pip install -e .
python -m my_etl.workflow
```

## Running the generated tests

```bash
pytest
```
17 changes: 9 additions & 8 deletions dotflow/cli/commands/init.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
"""Command init module"""

from os import system

from cookiecutter.main import cookiecutter
from rich import print # type: ignore

from dotflow.cli.command import Command
from dotflow.settings import Settings as settings

TEMPLATE_REPO = "https://github.com/dotflow-io/template"


class InitCommand(Command):
def setup(self):
if settings.GITIGNORE.exists():
system("echo '\n\n# Dotflow\n.output' >> .gitignore")
print(
settings.INFO_ALERT,
f"Installation complete! The ({settings.GITIGNORE.resolve()}) file has been modified.",
)
cookiecutter(TEMPLATE_REPO)

print(
settings.INFO_ALERT,
"Project created!",
)
6 changes: 4 additions & 2 deletions dotflow/cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ def __init__(self, parser):
self.command()

def setup_init(self):
self.cmd_init = self.subparsers.add_parser("init", help="Init")
self.cmd_init = self.subparsers.add_parser(
"init", help="Scaffold a new dotflow project"
)
self.cmd_init = self.cmd_init.add_argument_group(
"Usage: dotflow init [OPTIONS]"
"Usage: dotflow init <project-name>"
)
self.cmd_init.set_defaults(exec=InitCommand)

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ nav:
- nav/learn/process-mode-parallel.md
- nav/learn/process-mode-parallel-group.md
- Dotflow CLI:
- nav/learn/cli/init.md
- nav/learn/cli/simple-start.md
- nav/learn/cli/with-initial-context.md
- nav/learn/cli/with-callback.md
Expand Down
Loading
Loading