Skip to content

Commit

Permalink
Add descriptions to listed rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Argmaster committed Feb 1, 2025
1 parent 250b226 commit 40124b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/pygerber/console/gerber.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,16 @@ def _parse_rules(rules: list[str]) -> Iterable[str]:


@gerber.command("list-lint-rules")
def list_lint_rules() -> None:
@click.option(
"-q", "--quiet", is_flag=True, help="Print only rule names without descriptions."
)
def list_lint_rules(*, quiet: bool) -> None:
"""List available linting rules."""
from pygerber.gerber.linter.rules import RULE_REGISTRY

for rule_id in RULE_REGISTRY:
click.echo(rule_id)
if quiet:
click.echo(rule_id)
else:
rule = RULE_REGISTRY[rule_id]()
click.echo(f"{rule_id}: {rule.get_violation_title()}")
5 changes: 3 additions & 2 deletions src/pygerber/gerber/linter/rules/GRB001.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class GRB001(Rule):

def get_violation_title(self) -> str:
"""Return a title of message that describes the rule violation."""
assert self.last_node is not None
return f"""Redundant {self.last_node.__qualname__} command."""
if self.last_node is not None:
return f"""Redundant {self.last_node.__qualname__} command."""
return "Redundant G01/G02/G03 command."

def get_violation_description(self) -> str:
"""Return a description of the rule violation."""
Expand Down

0 comments on commit 40124b9

Please sign in to comment.