Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass path list to CLI instead of a folder #10

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "rapidchecker"
version = "0.1.2"
version = "0.1.3"
description = " Grammar and format checker for ABB RAPID code. "
readme = "README.md"
requires-python = ">=3.10"
Expand Down
17 changes: 7 additions & 10 deletions rapidchecker/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from pathlib import Path

import click
from pyparsing import ParseBaseException
Expand All @@ -7,12 +8,12 @@
from rapidchecker.whitespace_checks import WhiteSpaceError

from .check import check_format
from .io import get_sys_files, read_sys_file
from .whitespace_checks import check_whitespace


def in_ignore_list(path: str, ignore_list: list[str]) -> bool:
return any(item in path for item in ignore_list)
def read_sys_file(path: str | Path) -> str:
with Path(path).open() as f:
return f.read()


def check_file(file_contents: str) -> list[ParseBaseException | WhiteSpaceError]:
Expand All @@ -24,15 +25,11 @@ def check_file(file_contents: str) -> list[ParseBaseException | WhiteSpaceError]


@click.command()
@click.argument("path", type=click.Path(exists=True))
@click.option("--ignore", multiple=True)
def cli(path: str, ignore: list[str]) -> None:
@click.argument("paths", nargs=-1, type=click.Path(exists=True, dir_okay=False))
def cli(paths: list[str]) -> None:
found_errors = False

for filepath in get_sys_files(path):
if in_ignore_list(str(filepath), ignore):
print("Skipping", filepath)
continue
for filepath in paths:
errors = check_file(read_sys_file(filepath))
if not errors:
continue
Expand Down
14 changes: 0 additions & 14 deletions rapidchecker/io.py

This file was deleted.

2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.