Skip to content

Commit

Permalink
Add generate command
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrucc-io committed Nov 20, 2024
1 parent 15e0373 commit dadf521
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ ENV/
.vscode/
.idea/

# Houseplant
ch/
6 changes: 6 additions & 0 deletions src/houseplant/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def migrate(version: str | None = None):
hp.migrate(version)


@app.command(name="generate")
def generate(name: str):
"""Generate a new migration."""
hp.generate(name)


@app.command(hidden=True)
def main():
"""Console script for houseplant."""
Expand Down
16 changes: 14 additions & 2 deletions src/houseplant/houseplant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Main module."""

import os
from rich.console import Console


Expand All @@ -9,9 +10,15 @@ def __init__(self):

def init(self):
"""Initialize a new houseplant project."""
# TODO: Implement initialization logic
self.console.print("Initializing new houseplant project...")
pass

# Create ch directory and migrations subdirectory
os.makedirs("ch/migrations", exist_ok=True)

# Create schema.yml file
open("ch/schema.yml", "a").close()

self.console.print("✨ Project initialized successfully!")

def migrate_status(self):
"""Show status of database migrations."""
Expand All @@ -31,3 +38,8 @@ def migrate_down(self, version: str | None = None):
def migrate(self, version: str | None = None):
"""Run migrations up to specified version."""
self.migrate_up(version)

def generate(self, name: str):
"""Generate a new migration."""
# TODO: Implement migration generation logic
pass

0 comments on commit dadf521

Please sign in to comment.