Skip to content

Commit

Permalink
Implement replay flag, templates listing subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
crossjam committed Mar 8, 2024
1 parent 84d0a5a commit 0bfd642
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions quarto_post_init/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def cli(log_format, log_level, log_file):


@cli.command(name="post")
def post():
@click.option("--replay / --no-replay", default=False)
def post(replay):
"""Create a new quarto post, from a template"""

cookiecutters = {}
Expand All @@ -53,4 +54,22 @@ def post():
"Choose a post template", choices=list(cookiecutters.keys())
).ask()

cookiecutter(str(cookiecutters[choice]))
cookiecutter(str(cookiecutters[choice]), replay=replay)


@cli.command(name="templates")
def list_templates():
"""List the available templates"""

cookiecutters = {}

for p in resources.files(templates).iterdir():
logging.info("Checking for template in %s", p)
if (p / "cookiecutter.json").is_file():
logging.info("cookiecutter template: %s", p)
cookiecutters[p.name] = p

click.echo(f"{len(cookiecutters)} templates")

for name, location in cookiecutters.items():
click.echo(f"\t{name} -> {str(location)}")

0 comments on commit 0bfd642

Please sign in to comment.