Created a setup_readline function for the code used to setup readline. The function has been moved to config.py, and will be called from main.py

This commit is contained in:
Richard Mwewa
2023-04-12 16:17:51 +02:00
committed by GitHub
parent 61188fe29e
commit 6a535ae856
3 changed files with 24 additions and 21 deletions

View File

@@ -146,6 +146,28 @@ def create_parser():
return parser
# Setup readline
def setup_readline():
if os.name == "nt":
try:
from pyreadline3 import Readline
except ImportError:
subprocess.run(['pip3', 'install', 'pyreadline3'], shell=False)
readline = Readline()
else:
import readline
def completer(text, state):
options = [i for i in commands if i.startswith(text)]
if state < len(options):
return options[state]
else:
return None
readline.parse_and_bind("tab: complete")
readline.set_completer(completer)
parser = create_parser()
args = parser.parse_args()

View File

@@ -3,6 +3,7 @@ from octosuite.octosuite import * # I drifted away from the 'pythonic way' here
def octosuite():
setup_readline()
try:
run = Octosuite()
path_finder()

View File

@@ -12,7 +12,7 @@ import subprocess
from datetime import datetime
from requests.auth import HTTPBasicAuth
from octosuite.banner import version_tag, banner
from octosuite.config import Tree, Text, Table, Prompt, Confirm, Markdown, xprint, create_parser, args, red, white, green, yellow, header_title, reset
from octosuite.config import Tree, Text, Table, Prompt, Confirm, Markdown, xprint, create_parser, setup_readline, args, red, white, green, yellow, header_title, reset
from octosuite.message_prefixes import ERROR, WARNING, PROMPT, POSITIVE, NEGATIVE, INFO # wondering why I name all the variables instead of just using the * wildcard?, because it's the pythonic way lol
# seriously now, the reason why I am doing this, is so that you know exactly what I am importing from a named module :)
from octosuite.helper import help_command, source_command, search_command, user_command, repo_command, \
@@ -27,26 +27,6 @@ from octosuite.csv_loggers import log_org_profile, log_user_profile, log_repo_pr
log_commits_search
if os.name == "nt":
try:
from pyreadline3 import Readline
except ImportError:
subprocess.run(['pip3', 'install', 'pyreadline3'], shell=False)
readline = Readline()
else:
import readline
def completer(text, state):
options = [i for i in commands if i.startswith(text)]
if state < len(options):
return options[state]
else:
return None
readline.parse_and_bind("tab: complete")
readline.set_completer(completer)
# path_finder()
# This function is responsible for creating/checking the availability of the (.logs, output, downloads) folders,
# enabling logging to automatically log network/user activity to a file, and logging the start of a session.