Skip to content

Commit

Permalink
Coloring, Clear Screen, Show ID
Browse files Browse the repository at this point in the history
Added simple coloring of terminal ( To be expanded apon),
Added a clear screen command,
Shows current shell id in the input prompt.
  • Loading branch information
Skiller9090 committed Aug 17, 2020
1 parent 336f1dd commit ac7c14e
Show file tree
Hide file tree
Showing 312 changed files with 16,555 additions and 14,527 deletions.
12 changes: 8 additions & 4 deletions libs/LuciferArgParse.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from .LuciferShell import Shell
import argparse
import sys
import os
import sys

from .LuciferShell import Shell
from .LuciferManager import LuciferManager


class VAAETParser(argparse.ArgumentParser):
def __init__(self, lucifer_manager, *args, **kwargs):
def __init__(self, lucifer_manager: LuciferManager, *args, **kwargs):
super().__init__(args, kwargs)
self.luciferManager = lucifer_manager

def error_usage(self, message):
def error_usage(self, message: str):
sys.stderr.write('error: %s\n' % message)
self.print_help()
sys.exit(os.EX_USAGE)
Expand All @@ -23,6 +25,8 @@ def check_gui(self):
self.luciferManager.gui = True
print("Show GUI")
else:
self.luciferManager.colorama.init(autoreset=True)
print(self.luciferManager.termcolor.colored("Lucifer Prototype 1", "red", attrs=["bold", "underline"]))
self.luciferManager.main_shell = Shell(self.luciferManager.next_shell_id, self.luciferManager)
self.luciferManager.next_shell_id += 1
self.luciferManager.main_shell.spawn()
5 changes: 5 additions & 0 deletions libs/LuciferManager.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from . import termcolor
from . import colorama


class LuciferManager:
def __init__(self):
self.main_shell = None
self.alternative_shells = []
self.gui = False
self.next_shell_id = 0
self.colorama = colorama
self.termcolor = termcolor
52 changes: 29 additions & 23 deletions libs/LuciferShell.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .utils import check_int
from .utils import check_int, clear_screen


class Shell:
Expand All @@ -22,24 +22,25 @@ def __init__(self, ID, lucifer_manager):
set_name - Sets current shells name EX: set_name <name>
set_name_id - Set a shells name by id EX: set_name_id <id> <name>
close - Closes current shell
clear - Clear screen
id - Displays current shell's id
exit - Exits the program, can also use quit to do the same
name - Shows name of current shell"""
self.name = "Shell " if not self.is_main else "Main Shell"

def getIn(self):
self.shell_in = input(f"{self.program_name}|{self.module}|> ")
self.shell_in = input(f"{self.program_name}|{self.module}|{self.id}> ")

def print_id(self):
print(f"Shell ID: {self.id}")

def print_name(self):
print(f"Shell Name: {self.name}")

def set_name(self, name):
def set_name(self, name: str):
self.name = name

def set_name_id(self, ID, name):
def set_name_id(self, ID: int, name: str):
if ID == 0:
self.luciferManager.main_shell.name = name
print(f"{ID} => {name}")
Expand All @@ -59,18 +60,16 @@ def parseShellIn(self):
com_args.remove("")
if len(com_args) == 0:
return
if len(com_args) == 1:
command = com_args[0].lower()
if command == "help" or command == "h":
self.help()
return
com = com_args[0].lower().rstrip()
if com == "set":
if com == "help" or com == "h":
self.help()
return
elif com == "set":
com_args.pop(0)
com_args = " ".join(com_args)
self.command_set(com_args)
return
if com == "show":
elif com == "show":
if len(com_args) > 1:
if com_args[1].lower().strip() == "options" or com_args[1].lower().strip() == "vars":
self.show_options()
Expand All @@ -79,16 +78,16 @@ def parseShellIn(self):
print("Please enter a valid argument: options or modules")
else:
print("Please specify options or modules to show!")
if com == "quit" or com == "exit":
elif com == "quit" or com == "exit":
print("Thank you for using Lucifer, see you next time!")
exit(0)
if com == "id":
elif com == "id":
self.print_id()
return
if com == "spawn_shell":
elif com == "spawn_shell":
self.spawn_shell()
return
if com == "open_shell":
elif com == "open_shell":
if len(com_args) > 1:
openid = com_args[1].rstrip()
if check_int(openid):
Expand All @@ -111,32 +110,38 @@ def parseShellIn(self):
else:
print("Please specify a valid ID")
return
if com == "close":
elif com == "close":
return 7
if com == "show_shells":
elif com == "show_shells":
print("Main Shell => 0")
for shell in self.luciferManager.alternative_shells:
print(f"{shell.name} => {shell.id}")
return
if com == "name":
elif com == "name":
self.print_name()
return
if com == "set_name":
elif com == "set_name":
if len(com_args) > 1:
com_args.pop(0)
self.set_name(" ".join(com_args))
return
if com == "set_name_id":
elif com == "set_name_id":
if len(com_args) > 1:
ID = com_args[1].rstrip()
if check_int(ID):
for i in range(2):
com_args.pop(0)
self.set_name_id(int(ID), " ".join(com_args))
return
else:
print("Not a valid ID")
return
else:
print("Please add a valid ID")
return
elif com == "clear":
print(self.luciferManager.colorama.ansi.clear_screen())
return
return

def help(self):
Expand All @@ -149,7 +154,7 @@ def spawn(self):
if signal == 7:
break

def command_set(self, var_string):
def command_set(self, var_string: str):
vsl = var_string.split(" ")
var = vsl.pop(0).rstrip()
if var != "":
Expand All @@ -162,11 +167,12 @@ def command_set(self, var_string):
def spawn_shell(self):
self.luciferManager.alternative_shells.append(Shell(self.luciferManager.next_shell_id, self.luciferManager))
self.luciferManager.next_shell_id += 1
self.luciferManager.alternative_shells[-1].name += str(self.luciferManager.next_shell_id-1)
print(f"Opened New Shell With ID: {self.luciferManager.next_shell_id-1}")
self.luciferManager.alternative_shells[-1].name += str(self.luciferManager.next_shell_id - 1)
print(f"Opened New Shell With ID: {self.luciferManager.next_shell_id - 1}")

def show_options(self):
print(self.vars)

# help
# show <options/modules>
# use <module>
Expand Down
Binary file modified libs/__pycache__/LuciferArgParse.cpython-38.pyc
Binary file not shown.
Binary file modified libs/__pycache__/LuciferManager.cpython-38.pyc
Binary file not shown.
Binary file modified libs/__pycache__/LuciferShell.cpython-38.pyc
Binary file not shown.
Binary file modified libs/__pycache__/termcolor.cpython-38.pyc
Binary file not shown.
Binary file modified libs/__pycache__/utils.cpython-38.pyc
Binary file not shown.
55 changes: 54 additions & 1 deletion libs/argparse-1.4.0.dist-info/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
{"license": "Python Software Foundation License", "name": "argparse", "metadata_version": "2.0", "generator": "bdist_wheel (0.24.0)", "summary": "Python command-line parsing library", "platform": "any", "version": "1.4.0", "extensions": {"python.details": {"project_urls": {"Home": "https://github.com/ThomasWaldmann/argparse/"}, "document_names": {"description": "DESCRIPTION.rst"}, "contacts": [{"role": "author", "email": "tw@waldmann-edv.de", "name": "Thomas Waldmann"}]}}, "keywords": ["argparse", "command", "line", "parser", "parsing"], "classifiers": ["Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: Python Software Foundation License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 3", "Programming Language :: Python :: 2.3", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Software Development"]}
{
"license": "Python Software Foundation License",
"name": "argparse",
"metadata_version": "2.0",
"generator": "bdist_wheel (0.24.0)",
"summary": "Python command-line parsing library",
"platform": "any",
"version": "1.4.0",
"extensions": {
"python.details": {
"project_urls": {
"Home": "https://github.com/ThomasWaldmann/argparse/"
},
"document_names": {
"description": "DESCRIPTION.rst"
},
"contacts": [
{
"role": "author",
"email": "tw@waldmann-edv.de",
"name": "Thomas Waldmann"
}
]
}
},
"keywords": [
"argparse",
"command",
"line",
"parser",
"parsing"
],
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: Python Software Foundation License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 2.3",
"Programming Language :: Python :: 2.4",
"Programming Language :: Python :: 2.5",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.0",
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Topic :: Software Development"
]
}
25 changes: 13 additions & 12 deletions libs/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
"""

__version__ = '1.4.0' # we use our own version number independant of the
# one in stdlib and we release this on pypi.
# one in stdlib and we release this on pypi.

__external_lib__ = True # to make sure the tests really test THIS lib,
# not the builtin one in Python stdlib
# not the builtin one in Python stdlib

__all__ = [
'ArgumentParser',
Expand All @@ -87,7 +87,6 @@
'ZERO_OR_MORE',
]


import copy as _copy
import os as _os
import re as _re
Expand Down Expand Up @@ -132,6 +131,7 @@ def _callable(obj):
REMAINDER = '...'
_UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args'


# =============================
# Utility functions and classes
# =============================
Expand Down Expand Up @@ -592,7 +592,8 @@ def format(tuple_size):
if isinstance(result, tuple):
return result
else:
return (result, ) * tuple_size
return (result,) * tuple_size

return format

def _format_args(self, action, default_metavar):
Expand Down Expand Up @@ -645,7 +646,7 @@ def _split_lines(self, text, width):
def _fill_text(self, text, width, indent):
text = self._whitespace_matcher.sub(' ', text).strip()
return _textwrap.fill(text, width, initial_indent=indent,
subsequent_indent=indent)
subsequent_indent=indent)

def _get_help_string(self, action):
return action.help
Expand Down Expand Up @@ -698,7 +699,7 @@ def _get_action_name(argument):
if argument is None:
return None
elif argument.option_strings:
return '/'.join(argument.option_strings)
return '/'.join(argument.option_strings)
elif argument.metavar not in (None, SUPPRESS):
return argument.metavar
elif argument.dest not in (None, SUPPRESS):
Expand Down Expand Up @@ -1048,7 +1049,6 @@ def __call__(self, parser, namespace, values, option_string=None):


class _SubParsersAction(Action):

class _ChoicesPseudoAction(Action):

def __init__(self, name, aliases, help):
Expand All @@ -1057,7 +1057,7 @@ def __init__(self, name, aliases, help):
metavar += ' (%s)' % ', '.join(aliases)
sup = super(_SubParsersAction._ChoicesPseudoAction, self)
sup.__init__(option_strings=[], dest=dest, help=help,
metavar=metavar)
metavar=metavar)

def __init__(self,
option_strings,
Expand Down Expand Up @@ -1179,6 +1179,7 @@ def __repr__(self):
args_str = ', '.join([repr(arg) for arg in args if arg is not None])
return '%s(%s)' % (type(self).__name__, args_str)


# ===========================
# Optional and Positional Parsing
# ===========================
Expand Down Expand Up @@ -1285,7 +1286,6 @@ def get_default(self, dest):
return action.default
return self._defaults.get(dest, None)


# =======================
# Adding argument actions
# =======================
Expand Down Expand Up @@ -1622,6 +1622,7 @@ def __init__(self,
# register types
def identity(string):
return string

self.register('type', None, identity)

# add help and version arguments if necessary
Expand All @@ -1632,12 +1633,12 @@ def identity(string):
default_prefix = prefix_chars[0]
if self.add_help:
self.add_argument(
default_prefix+'h', default_prefix*2+'help',
default_prefix + 'h', default_prefix * 2 + 'help',
action='help', default=SUPPRESS,
help=_('show this help message and exit'))
if self.version:
self.add_argument(
default_prefix+'v', default_prefix*2+'version',
default_prefix + 'v', default_prefix * 2 + 'version',
action='version', default=SUPPRESS,
version=self.version,
help=_("show program's version number and exit"))
Expand Down Expand Up @@ -2105,7 +2106,7 @@ def _parse_optional(self, arg_string):
# if multiple actions match, the option string was ambiguous
if len(option_tuples) > 1:
options = ', '.join([option_string
for action, option_string, explicit_arg in option_tuples])
for action, option_string, explicit_arg in option_tuples])
tup = arg_string, options
self.error(_('ambiguous option: %s could match %s') % tup)

Expand Down
1 change: 1 addition & 0 deletions libs/colorama-0.4.3.dist-info/INSTALLER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
Loading

0 comments on commit ac7c14e

Please sign in to comment.