Skip to content

Commit

Permalink
Switched from typer to click.
Browse files Browse the repository at this point in the history
  • Loading branch information
coordt committed Jun 12, 2022
1 parent 7f02db3 commit d66f3f0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
28 changes: 20 additions & 8 deletions cookie_composer/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,38 @@

from pathlib import Path

import typer
import rich_click as click

from cookie_composer._commands import _create
from cookie_composer.commands.create import create_cmd

app = typer.Typer()

@click.group()
def cli():
"""Rendering templates using composition."""
pass

@app.command()
def create(path_or_url: str, output_dir: Optional[Path] = None):

@cli.command()
@click.argument("path_or_url", type=str, required=True)
@click.argument(
"output_dir",
required=False,
default=lambda: Path.cwd(),
type=click.Path(exists=True, dir_okay=True, file_okay=False, resolve_path=True),
)
def create(path_or_url: str, output_dir: Optional[Path]):
"""
Create a project from a template or configuration.
Args:
path_or_url: The path or URL to the template or composition file
output_dir: Where to write the output
"""
_create.create(path_or_url, output_dir)
create_cmd(path_or_url, output_dir)


@app.command()
@cli.command()
@click.argument("path_or_url", type=str, required=True)
def add(path_or_url: str):
"""
Add a template or configuration to an existing project.
Expand All @@ -32,7 +44,7 @@ def add(path_or_url: str):
"""


@app.command()
@cli.command()
def update():
"""
Update the project to the latest version of each template.
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ packages = find:

[options.entry_points]
console_scripts =
cookie-composer = cookie_composer.cli:app
cookie-composer = cookie_composer.cli:cli

[options.packages.find]
exclude =
Expand Down

0 comments on commit d66f3f0

Please sign in to comment.