adding restock command
This commit is contained in:
parent
e0cb01ba2c
commit
a6c101b01b
|
@ -29,7 +29,7 @@ pelican-yaml-metadata = { git = "https://github.com/pR0Ps/pelican-yaml-metadata.
|
|||
dnd-npcs = { git = "https://github.com/evilchili/dnd-npcs", branch = 'main' }
|
||||
elethis-cipher= { git = "https://github.com/evilchili/elethis-cipher", branch = 'main' }
|
||||
#dnd-rolltable = { git = "https://github.com/evilchili/dnd-rolltable", branch = 'main' }
|
||||
dnd-rolltable = { file = "../../dnd-rolltable/dist/dnd_rolltable-1.1.5-py3-none-any.whl" }
|
||||
dnd-rolltable = { file = "../../dnd-rolltable/dist/dnd_rolltable-1.1.9-py3-none-any.whl" }
|
||||
|
||||
[tool.poetry.scripts]
|
||||
site = "site_tools.cli:app"
|
||||
|
|
|
@ -17,6 +17,7 @@ from pelican import main as pelican_main
|
|||
from time import sleep
|
||||
|
||||
from site_tools.content_manager import create
|
||||
from rolltable.tables import RollTable
|
||||
|
||||
|
||||
CONFIG = {
|
||||
|
@ -103,7 +104,7 @@ def watch() -> None:
|
|||
print(f"Watching {import_path}. CTRL+C to exit.")
|
||||
while True:
|
||||
watcher.examine()
|
||||
sleep(1)
|
||||
sleep(5)
|
||||
|
||||
|
||||
@app.command()
|
||||
|
@ -158,6 +159,44 @@ def publish() -> None:
|
|||
))
|
||||
|
||||
|
||||
@app.command()
|
||||
def restock(source: str = typer.Argument(
|
||||
...,
|
||||
help='The source file for the store.'
|
||||
),
|
||||
frequency: str = typer.Option(
|
||||
'default',
|
||||
help='use the specified frequency from the source file'),
|
||||
die: int = typer.Option(
|
||||
20,
|
||||
help='The size of the die for which to create a table'),
|
||||
template_dir: str = typer.Argument(
|
||||
CONFIG['templates_path'],
|
||||
help="Override the default location for markdown templates.",
|
||||
)
|
||||
) -> None:
|
||||
|
||||
rt = RollTable(
|
||||
[Path(source).read_text()],
|
||||
frequency=frequency,
|
||||
die=die,
|
||||
hide_rolls=True
|
||||
)
|
||||
store = rt.datasources[0].metadata['store']
|
||||
|
||||
click.edit(filename=create(
|
||||
content_type='post',
|
||||
title=store['title'],
|
||||
template_dir=template_dir,
|
||||
category='stores',
|
||||
template='store',
|
||||
extra_context=dict(
|
||||
inventory=rt.as_markdown,
|
||||
**store
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
@app.command()
|
||||
def new(
|
||||
content_type: ContentType = typer.Argument(
|
||||
|
|
|
@ -7,7 +7,8 @@ from site_tools import SETTINGS
|
|||
|
||||
|
||||
def create(content_type: str, title: str, template_dir: str,
|
||||
category: str = None, template: str = None) -> str:
|
||||
category: str = None, source: str = None, template: str = None,
|
||||
extra_context: dict = {}) -> str:
|
||||
"""
|
||||
Return the path to a new source file.
|
||||
"""
|
||||
|
@ -41,6 +42,7 @@ def create(content_type: str, title: str, template_dir: str,
|
|||
'title': title,
|
||||
'tags': content_type,
|
||||
'date': datetime.datetime.now(),
|
||||
'filename': str(relpath / target_filename)
|
||||
'filename': str(relpath / target_filename),
|
||||
**extra_context
|
||||
})
|
||||
return dest
|
||||
|
|
Loading…
Reference in New Issue
Block a user