Testapp is a Python CLI built around a REPL (Read-Eval-Print Loop).
src/
__init__.py — package marker
main.py — entry point; contains the REPL loop
commands.py — command registry and handlers
tests/
__init__.py
test_commands.py
test_main.py
requirements.txt — pytest (dev)
src/commands.py defines two things:
COMMAND_DESCRIPTIONS — {name: one-line description} used by helpCOMMANDS — {name: callable} mapping command names to handler functionsEvery handler takes no arguments and returns a string. The REPL prints that string.
To add a new command:
_my_command() -> strCOMMAND_DESCRIPTIONS with a descriptionCOMMANDS under its namesrc/main.py)print welcome message
loop:
print "> " prompt
read input → strip whitespace → lowercase
if empty: skip
if in COMMANDS: call handler, print result
else: print "Unknown command" error
on KeyboardInterrupt: exit loop cleanly