zephyr/scripts/pylib/pytest-twister-harness/tests/resources/shell_simulator.py
Piotr Golyzniak e326015cda scripts: pytest: add Shell helper unit tests
Add unit tests dedicated for Shell helper sample class.
Add shell_simulator_script.py script to simulate shell application
behavior.

Signed-off-by: Piotr Golyzniak <piotr.golyzniak@nordicsemi.no>
2023-08-30 06:39:55 -04:00

31 lines
628 B
Python

# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: Apache-2.0
"""
Simple shell simulator.
"""
import sys
from zen_of_python import zen_of_python
PROMPT = 'uart:~$ '
def main() -> int:
print('Start shell simulator', flush=True)
print(PROMPT, end='', flush=True)
for line in sys.stdin:
line = line.strip()
print(line, flush=True)
if line == 'quit':
break
elif line == 'zen':
for zen_line in zen_of_python:
print(zen_line, flush=True)
print(PROMPT, end='', flush=True)
if __name__ == '__main__':
main()