Skip to content

Commit ff445e8

Browse files
Merge pull request #121 from dotflow-io/feature/107
⚙️ FEATURE-#107: Rewrite dotflow init with interactive cookiecutter template
2 parents 0ff3cde + 8afe8dc commit ff445e8

6 files changed

Lines changed: 235 additions & 41 deletions

File tree

docs/nav/learn/cli/init.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Init
2+
3+
Scaffold a new dotflow project interactively.
4+
5+
```bash
6+
dotflow init
7+
```
8+
9+
The command prompts for project configuration:
10+
11+
```
12+
project_name [my-pipeline]: my-etl
13+
storage [default]: s3
14+
```
15+
16+
Output:
17+
18+
```
19+
my-etl/
20+
├── my_etl/
21+
│ ├── __init__.py
22+
│ ├── actions.py
23+
│ └── workflow.py
24+
├── tests/
25+
│ └── test_workflow.py
26+
├── pyproject.toml
27+
└── README.md
28+
```
29+
30+
## Storage options
31+
32+
| Option | Description |
33+
|--------|-------------|
34+
| `default` | In-memory, no persistence |
35+
| `file` | Local disk (StorageFile) |
36+
| `s3` | AWS S3 (StorageS3) — adds `dotflow[aws]` dependency |
37+
| `gcs` | Google Cloud Storage (StorageGCS) — adds `dotflow[gcp]` dependency |
38+
39+
## Running the generated project
40+
41+
```bash
42+
cd my-etl
43+
pip install -e .
44+
python -m my_etl.workflow
45+
```
46+
47+
## Running the generated tests
48+
49+
```bash
50+
pytest
51+
```

dotflow/cli/commands/init.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
"""Command init module"""
22

3-
from os import system
4-
3+
from cookiecutter.main import cookiecutter
54
from rich import print # type: ignore
65

76
from dotflow.cli.command import Command
87
from dotflow.settings import Settings as settings
98

9+
TEMPLATE_REPO = "https://github.com/dotflow-io/template"
10+
1011

1112
class InitCommand(Command):
1213
def setup(self):
13-
if settings.GITIGNORE.exists():
14-
system("echo '\n\n# Dotflow\n.output' >> .gitignore")
15-
print(
16-
settings.INFO_ALERT,
17-
f"Installation complete! The ({settings.GITIGNORE.resolve()}) file has been modified.",
18-
)
14+
cookiecutter(TEMPLATE_REPO)
15+
16+
print(
17+
settings.INFO_ALERT,
18+
"Project created!",
19+
)

dotflow/cli/setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ def __init__(self, parser):
3636
self.command()
3737

3838
def setup_init(self):
39-
self.cmd_init = self.subparsers.add_parser("init", help="Init")
39+
self.cmd_init = self.subparsers.add_parser(
40+
"init", help="Scaffold a new dotflow project"
41+
)
4042
self.cmd_init = self.cmd_init.add_argument_group(
41-
"Usage: dotflow init [OPTIONS]"
43+
"Usage: dotflow init <project-name>"
4244
)
4345
self.cmd_init.set_defaults(exec=InitCommand)
4446

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ nav:
162162
- nav/learn/process-mode-parallel.md
163163
- nav/learn/process-mode-parallel-group.md
164164
- Dotflow CLI:
165+
- nav/learn/cli/init.md
165166
- nav/learn/cli/simple-start.md
166167
- nav/learn/cli/with-initial-context.md
167168
- nav/learn/cli/with-callback.md

0 commit comments

Comments
 (0)