Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfraney committed Jan 4, 2025
1 parent 3916f83 commit 7eab558
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions blurry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import pkgutil
import shutil
import sys
import tomllib
from copy import deepcopy
from datetime import datetime
from pathlib import Path
Expand All @@ -21,6 +22,7 @@
from rich.progress import Progress
from rich.progress import TaskProgressColumn
from rich.progress import TextColumn
from rich.prompt import Prompt

from blurry.async_typer import AsyncTyper
from blurry.cli import print_blurry_name
Expand Down Expand Up @@ -240,6 +242,56 @@ def clean_build_directory():
pass


blurry_config_organization_section = """
[blurry.schema_data.sourceOrganization]
name = "{project_name}"
""".strip()


blurry_config_template = """
[blurry]
domain = "{domain}"
{organization_section}
""".strip()


@app.command(name="init")
def init():
"""Initializes a new Blurry project"""
update_settings()
blurry_config_file = Path("blurry.toml")
if blurry_config_file.exists():
print("Blurry project already initialized.")
return
domain = Prompt.ask("What is your website's domain?")
project_name = Prompt.ask(
"What is the name of your company, project, or website? (optional)",
default=None,
)

organization_section = (
blurry_config_organization_section.format(project_name=project_name)
if project_name
else ""
)

config_text = blurry_config_template.format(
domain=domain, organization_section=organization_section
)

try:
tomllib.loads(config_text)
except tomllib.TOMLDecodeError as e:
print(f"Error in configuration file: {e}.")
print("Please check your input and try again.")
exit(1)

blurry_config_file.write_text(config_text)

print("Blurry project initialized!")


@app.async_command()
async def build(release=True, clean: bool = False):
"""Generates HTML content from Markdown files."""
Expand Down

0 comments on commit 7eab558

Please sign in to comment.