Improve command output when no files are found

This commit is contained in:
Dunedan 2024-09-22 15:26:23 +02:00
parent d141b8bec6
commit 8a19698f38
Signed by: Dunedan
GPG Key ID: 885B16854284E0B2

View File

@ -26,7 +26,7 @@ from pathlib import Path
from typing import Generator, List, Tuple
import click
from click import UsageError
from click import ClickException
from dennis.linter import ERROR, LintedEntry, Linter, LintMessage, LintRule, get_lint_rules
from dennis.templatelinter import TemplateLinter
from dennis.templatelinter import get_lint_rules as get_template_lint_rules
@ -241,7 +241,7 @@ def run(
files_to_check = po_files
if len(files_to_check) == 0:
raise UsageError("Found no files to check.")
raise ClickException("Found no files to check.")
return lint_files(files_to_check), len(files_to_check)
@ -250,7 +250,11 @@ def run(
@click.option("--locale", help="Only check translations for the given locale")
@click.argument("files", nargs=-1, type=click.Path(exists=True, resolve_path=True, path_type=Path))
def cli(locale, files):
"""CLI entry point."""
"""Lint PO- and POT-files.
Provide one or multiple FILES to check. If omitted all files in
the project will be checked.
"""
lint_results, num_checked_files = run(locale, files)
print_results(lint_results, num_checked_files)