Module

cli.helpers.site_loader

Helper for loading Site instances from CLI arguments.

Functions

_check_parent_project_conflict
Check if parent directories contain another Bengal project. This helps catch a common mistake: run…
2 None
def _check_parent_project_conflict(root_path: Path, cli: CLIOutput) -> None

Check if parent directories contain another Bengal project.

This helps catch a common mistake: running bengal from a subdirectory of another Bengal project (e.g., running from project root when the actual site is in a 'site/' subdirectory, or vice versa).

Parameters 2

Name Type Default Description
root_path Path

The resolved site root path

cli CLIOutput

CLI output for warnings

_count_markdown_files
Count markdown files in a directory tree.
1 int
def _count_markdown_files(directory: Path) -> int

Count markdown files in a directory tree.

Parameters 1

Name Type Default Description
directory Path

Returns

int

_check_subdirectory_site
Check if a subdirectory contains what looks like the actual site. Common case: running from projec…
2 None
def _check_subdirectory_site(root_path: Path, cli: CLIOutput) -> None

Check if a subdirectory contains what looks like the actual site.

Common case: running from project root when site/ subdirectory contains the actual Bengal site with content.

Parameters 2

Name Type Default Description
root_path Path

The resolved site root path

cli CLIOutput

CLI output for warnings

load_site_from_cli
Load a Site instance from CLI arguments with consistent error handling.
5 Site
def load_site_from_cli(source: str = '.', config: str | None = None, environment: str | None = None, profile: str | None = None, cli: CLIOutput | None = None) -> Site

Load a Site instance from CLI arguments with consistent error handling.

Parameters 5

Name Type Default Description
source str '.'

Source directory path (default: current directory)

config str | None None

Optional config file path

environment str | None None

Optional environment name (local, preview, production)

profile str | None None

Optional profile name (writer, theme-dev, dev)

cli CLIOutput | None None

Optional CLIOutput instance (creates new if not provided)

Returns

Site

Site instance