mirror of
https://github.com/bellingcat/octosuite.git
synced 2026-06-08 03:18:35 +03:00
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:
@@ -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()
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user