Bash Menu Builder
Project description
Bash Menu Builder
This package help you build menu for yours console scripts
Installation
For install package to your project use this command:
pip3 install bash-menu-builder
Use
Example of use menu:
from bash_menu_builder import View, MenuItemDto
def banner() -> str:
return 'I\'m Banner Text'
def script_one():
# Call Services or do something
def script_two():
# Call Services or do something
def script_three():
# Call Services or do something
if __name__ == "__main__":
View([
MenuItemDto('Script Title 1', 'one', script_one),
MenuItemDto('Script Title 2', 'two', script_two),
MenuItemDto('Script Title 3', 'one-more', script_three),
], banner())
Draw menu
The menu draw via class View
which get params of array with DTOs and text of banner (optional)
The MenuItemDto have 3 params def __init__(self, title: str, option_name: str, handler: object):
title: str
- the title of menu itemoption_name: str
- the option name for call menu via consolehandler: object
- the handler of menu item. What exactly script do after select this menu item.
How it works
After select menu number and press Enter will run script in function. When script finish process menu will draw again.
Also you can call script without drawing menu. Just set option when call python script file, ex. python3 main.py --one-more
In this case will run script for menu 'Script Title 3'. When script finish process menu will not draw again and program will close.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.