Skip to content

Commit 0e99637

Browse files
authored
issue-14 (#15)
1 parent 2161ded commit 0e99637

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

src/render_engine_cli/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
validate_module_site,
2626
)
2727

28-
click.echo("[bold green]In the new CLI[/bold green]", color=True)
29-
3028

3129
@click.group()
3230
def app():
@@ -87,9 +85,10 @@ def init(template: str, extra_context: str, no_input: bool, output_dir: Path, co
8785
try:
8886
from cookiecutter.main import cookiecutter
8987
except ImportError:
90-
click.echo(
88+
click.secho(
9189
"You need to install cookiecutter to use this command. Run `pip install cookiecutter` to install it.",
9290
err=True,
91+
fg="red",
9392
)
9493
raise click.Exit(0)
9594
extra_context = json.loads(extra_context) if extra_context else None

src/render_engine_cli/utils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,14 @@ def load_config(self, config_file: str = CONFIG_FILE_NAME):
4848
try:
4949
with open(config_file) as stored_config_file:
5050
try:
51-
stored_config = toml.load(stored_config_file).get("tool.render-engine", {}).get("cli", {})
51+
stored_config = (
52+
toml.load(stored_config_file).get("tool", {}).get("render-engine", {}).get("cli", {})
53+
)
5254
except TomlDecodeError as exc:
53-
click.echo(f"Encountered an error while parsing {config_file} - {exc}.")
55+
click.echo(
56+
f"{click.style(f'Encountered an error while parsing {config_file}', fg='red')}\n{exc}\n",
57+
err=True,
58+
)
5459
else:
5560
click.echo(f"Config loaded from {config_file}")
5661
except FileNotFoundError:

tests/test_cli.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import frontmatter
22
import pytest
3-
import toml
43
from render_engine import Collection, Page, Site
54

65
from render_engine_cli.utils import (
@@ -106,12 +105,14 @@ def test_split_args_error_handling():
106105

107106
def test_config_loading_with_valid_config(tmp_path, monkeypatch):
108107
"""Tests config loading from pyproject.toml (2025.5.1b1 feature)"""
109-
config_content = {
110-
"tool.render-engine": {"cli": {"module": "myapp", "site": "MySite", "collection": "MyCollection"}}
111-
}
112-
108+
config_content = """
109+
[tool.render-engine.cli]
110+
module = "myapp"
111+
site = "MySite"
112+
collection = "MyCollection"
113+
"""
113114
config_file = tmp_path / "pyproject.toml"
114-
config_file.write_text(toml.dumps(config_content))
115+
config_file.write_text(config_content)
115116

116117
# Change to temp directory for config loading test
117118
monkeypatch.chdir(tmp_path)

0 commit comments

Comments
 (0)