Skip to content

Commit

Permalink
FEATURE : First attempt at templater.
Browse files Browse the repository at this point in the history
  • Loading branch information
crdoconnor committed Oct 31, 2023
1 parent bcec231 commit eaec2d0
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
3 changes: 2 additions & 1 deletion hitch/story/quickstart.story
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ Quickstart:
- hitchskeleton:
cmd: website
output: |
hello
Cloning into 'hitchstory'...
Set up. Run ./run.sh make
37 changes: 36 additions & 1 deletion hitchskeleton/template.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
import click
from commandlib import Command
from pathlib import Path
import os
from sys import exit
import shutil


@click.command()
def website():
click.echo("hello")
homedir = Path(os.path.expanduser("~"))
cacheroot = homedir / ".cache"
cachedir = cacheroot / "hitchskeleton"
currentdir = Path(os.getcwd())
newhitchdir = currentdir / "hitch"

if not cacheroot.exists():
cacheroot.mkdir()

if cachedir.exists():
cachedir.rmtree()
cachedir.mkdir()

if newhitchdir.exists():
print("Hitch already set up in this directory. Delete the folder and try again")
exit(1)

git = Command("git")

git("clone", "https://github.com/hitchdev/hitchstory.git").in_dir(cachedir).run()

shutil.copytree(
cachedir / "hitchstory" / "examples" / "website" / "hitch", newhitchdir
)

for existing_story in newhitchdir.joinpath("story").glob("*.story"):
os.remove(existing_story)

os.remove(newhitchdir / "selectors" / "selectors.yml")

click.echo("Set up. Run ./run.sh make")
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ classifiers = [
"Natural Language :: English",
]
dependencies = [
"jinja2>=3.1.2",
"click>=8.1.3",
"python-slugify>=7.0.0",
"commandlib>=0.3.5",
"path.py>12.0",
]
dynamic = ["version", "readme"]

Expand Down

0 comments on commit eaec2d0

Please sign in to comment.