TTY OV  1
A cross platform python terminal
Loading...
Searching...
No Matches
polyguard.src.cli Namespace Reference

Data Structures

class  CLI
 

Functions

 _iter_input_lines (Iterable[str] stream)
 
 _resolve_lang (str token)
 
int main (Optional[List[str]] argv=None)
 

Detailed Description

# +==== BEGIN polyguard =================+
# LOGO:
#       input
# 
#    @#$%!  hello
#      |     |
#      +--+--+
#         |
#         v
#   +------------+
#   | POLY GUARD |
#   +------------+
#     |        |
#     v        v
#  BLOCKED  PASSED
#    KO       OK
# /STOP
# PROJECT: polyguard
# FILE: cli.py
# CREATION DATE: 21-03-2026
# LAST Modified: 19:47:9 21-03-2026
# DESCRIPTION:
# A module that provides a set of swearwords to listen to when filtering while allowing to toggle on and off different languages.
# /STOP
# COPYRIGHT: (c) Henry Letellier
# PURPOSE: This is the code in charge of simulating a pseudo tty for the ones that start the module without piping content into it.
# TTY-friendly CLI wrapper for PolyGuard.
#
# Provides a simple entrypoint that accepts a path to the DB and a test
# word to check. The CLI is intentionally minimal to be easy to extend.
# // AR
# +==== END polyguard =================+

Function Documentation

◆ _iter_input_lines()

polyguard.src.cli._iter_input_lines ( Iterable[str] stream)
protected
Iterate over lines from a stream, yielding non-empty lines.

Strips trailing newlines from each line before yielding.

Args:
    stream: Iterable of strings (e.g., from sys.stdin).

Yields:
    str: Non-empty lines with trailing newlines removed.

Definition at line 44 of file cli.py.

◆ _resolve_lang()

polyguard.src.cli._resolve_lang ( str token)
protected
Resolve a user-provided token to a `POLY_CONST.Langs` member.

Accepts either the enum value ('en_uk') or the enum name ('EN_UK').
Returns None if no match is found.

Definition at line 61 of file cli.py.

◆ main()

int polyguard.src.cli.main ( Optional[List[str]] argv = None)
CLI entrypoint for PolyGuard.

Dispatches to single-word check, stdin batch processing, or interactive
REPL based on arguments and whether stdin is a TTY.

Args:
    argv: Optional list of command-line arguments. If None, uses sys.argv.

Returns:
    int: Exit code (0 for success, non-zero for error).

Definition at line 411 of file cli.py.