TTY OV  1
A cross platform python terminal
Loading...
Searching...
No Matches
polyguard.src.cli.CLI Class Reference
Collaboration diagram for polyguard.src.cli.CLI:
Collaboration graph

Public Member Functions

 __init__ (self, PolyGuard guard)
 
int run_single (self, str word)
 
int run_stdin (self)
 
bool cmd_log (self, list[str] tokens)
 
bool cmd_langopt (self, list[str] tokens)
 
bool cmd_langs (self, list[str] tokens)
 
bool cmd_langstatus (self, list[str] tokens)
 
bool cmd_word (self, list[str] tokens)
 
int repl (self)
 

Data Fields

 guard = guard
 

Detailed Description

Simple CLI class for PolyGuard interactive and batch usage.

Kept at module level to allow import and unit testing.

Definition at line 81 of file cli.py.

Constructor & Destructor Documentation

◆ __init__()

polyguard.src.cli.CLI.__init__ ( self,
PolyGuard guard )

Definition at line 87 of file cli.py.

Member Function Documentation

◆ cmd_langopt()

bool polyguard.src.cli.CLI.cmd_langopt ( self,
list[str] tokens )
Enable or disable a specific language in the PolyGuard configuration.

Parses language code from tokens[1] and 'on'/'off' status from tokens[2],
then updates the guard's language configuration.

Args:
    tokens: Command tokens where tokens[1] is language and tokens[2]
        is 'on' or 'off'.

Returns:
    bool: Always returns True (command processed).

Definition at line 147 of file cli.py.

◆ cmd_langs()

bool polyguard.src.cli.CLI.cmd_langs ( self,
list[str] tokens )
List all available languages in the database with word counts.

Displays languages compactly on lines of ~80 characters, marking
enabled languages with [enabled] tag.

Args:
    tokens: Command tokens (not used).

Returns:
    bool: Always returns True (command processed).

Definition at line 181 of file cli.py.

◆ cmd_langstatus()

bool polyguard.src.cli.CLI.cmd_langstatus ( self,
list[str] tokens )
Display the current enabled/disabled status of all languages.

Lists each language code with its current 'on' or 'off' status as
determined by the guard's default language configuration.

Args:
    tokens: Command tokens (not used).

Returns:
    bool: Always returns True (command processed).

Definition at line 244 of file cli.py.

◆ cmd_log()

bool polyguard.src.cli.CLI.cmd_log ( self,
list[str] tokens )
Toggle logging output on or off.

Parses 'on' or 'off' from the second token and updates the guard and
sqlite handler's logging flags.

Args:
    tokens: Command tokens where tokens[1] should be 'on' or 'off'.

Returns:
    bool: Always returns True (command processed).

Definition at line 122 of file cli.py.

◆ cmd_word()

bool polyguard.src.cli.CLI.cmd_word ( self,
list[str] tokens )
Check a word, optionally for a specific language.

Supports multi-word phrases. If the final token matches a known language,
it is treated as the language filter. Returns the match status and any
matched words from the database (if a specific language is given).

Args:
    tokens: Command tokens where tokens[1:] is the word/phrase and
        tokens[-1] may be a language code.

Returns:
    bool: Always returns True (command processed).

Definition at line 267 of file cli.py.

◆ repl()

int polyguard.src.cli.CLI.repl ( self)
Run the interactive CLI REPL loop.

Accepts user input for words to check or colon-prefixed commands.
Supports batch processing from stdin and interactive commands like
':log', ':langopt', ':langs', ':langstatus', ':word', ':help', ':man'.

Returns:
    int: Always returns 0 on normal exit or interrupt.

Definition at line 322 of file cli.py.

◆ run_single()

int polyguard.src.cli.CLI.run_single ( self,
str word )
Check a single word and print the result.

Args:
    word: The word to check.

Returns:
    int: Always returns 0.

Definition at line 90 of file cli.py.

◆ run_stdin()

int polyguard.src.cli.CLI.run_stdin ( self)
Read lines from stdin and check each for profanity.

Outputs 'BLOCKED' or 'OK' for each line.

Returns:
    int: Always returns 0.

Definition at line 106 of file cli.py.

Field Documentation

◆ guard

polyguard.src.cli.CLI.guard = guard

Definition at line 88 of file cli.py.


The documentation for this class was generated from the following file: