34 lines
661 B
Python
34 lines
661 B
Python
import re
|
|
from pathlib import Path
|
|
|
|
from click import argument, command, echo
|
|
|
|
|
|
def check_path(path: Path) -> bool:
|
|
str_path = str(path)
|
|
|
|
if path.suffix == ".cs":
|
|
if re.search(r"^[a-zA-Z\\\/\._]*$", str_path) is None:
|
|
return False
|
|
else:
|
|
if re.search(r"^[a-z\\\/\._]*$", str_path) is None:
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
@command
|
|
@argument(
|
|
"paths",
|
|
nargs=-1,
|
|
)
|
|
def main(paths: list[str]) -> None:
|
|
has_error = False
|
|
for path in paths:
|
|
if not check_path(Path(path)):
|
|
echo(f"{path} doesn't follows convention")
|
|
has_error = True
|
|
|
|
if has_error:
|
|
exit(1)
|