Skip to content

Preflight

preflight

CronspellPreflightException

preflight(files: Annotated[list[Path], typer.Argument(..., help='One or more Paths.')], yamlpath: Annotated[str, typer.Option(--yamlpath, -p, show_default=False, help='yamlpath YAML_PATH')])

 * Takes a list of paths * validates expressions

Source code in src/cronspell/cli/preflight.py
def preflight(
    files: Annotated[
        list[Path],
        typer.Argument(
            ...,
            help="One or more Paths.",
        ),
    ],
    yamlpath: Annotated[
        str,
        typer.Option("--yamlpath", "-p", show_default=False, help="yamlpath YAML_PATH"),
    ],
):
    """
    \b
    * Takes a list of paths
    * validates expressions
    """

    for file in files:
        processor = get_processor(file)

        try:
            for token in processor.get_nodes(yamlpath, mustexist=True):
                parse(str(token).strip())
        except UnmatchedYAMLPathException as ex:
            msg = f"yamlpath {yamlpath} does not exist in {file}!"
            raise CronspellPreflightException(file, msg) from ex