-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Warning
Please note that this code uses my print_color
for more info go to https://github.com/Aydinhamedi/Python-color-print.
Start by setting up the configuration to suit your needs. You can do this by modifying the following lines:
REM CONF
set CLI_NAME="CHANGE THE NAME"
set python_min_VER=9For example, if you want the minimum Python version to be 3.6.x and the CLI name to be "Test", you would change the lines to:
REM CONF
set CLI_NAME=Test
set python_min_VER=6 Next, specify the Python packages your project requires in Data\requirements.txt. For example:
numpy
keras
Pillow
Open Data\CLI_main.py to customize the CLI.
Add any additional Python packages you need at the beginning of the file:
#pylib
import os
import sys
import difflib
import traceback
from datetime import datetime
from PrintColor.Print_color import print_ColorWarning
Do not remove any of the existing imports.
Define any global variables you need:
#global vars>>>
#CONST SYS
CLI_NAME = '`CHANGE THE NAME`' # your CLI name
CLI_Ver = '0.00' # your CLI ver
# ...
#normal global
# ...
#other
# ...Add any helper functions your CLI requires:
#HF>>>
# ... (helper funcs)Add functions for any commands your CLI supports:
#CF>>>
# ...Note
A help function is included by default.
Define the commands your CLI supports:
#CMT>>>
command_tuple = (
'help', # help
'exit', # Quit the CLI
'clear' # Clear the CLI
)And provide descriptions for each command:
cmd_descriptions = {
'help': 'Show the help menu with the list of all available commands'
}
cmd_descriptions_other = {
'exit': 'Quit the CLI',
'clear': 'Clear the CLI'
}Finally, add functionality for each command in the main function:
#main
def main():
#global
global Debug_m
#CLI loop
while True: #WT
#input manager
input_array = CLI_IM()
Debug('Input command', input_array) # Debug example usage
match input_array[0]: #MI
case 'help':
CI_help()
case 'IIE':
pass
case 'clear':
os.system('cls' if os.name == 'nt' else 'clear')
print(CLI_Info)
case 'debug':
print('Debug mode is ON...')
Debug_m = True
case 'exit':
raise KeyboardInterrupt
case _:
IEH(id = 'F[main],L1[WT],L2[MI],Error[nothing matched]', stop = False, DEV = False)This is where you define what happens when each command is entered.