diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6e4761 --- /dev/null +++ b/.gitignore @@ -0,0 +1,129 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/README.md b/README.md index c4fa682..aa4f617 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ or install from source ``` Usage: insh +or: insh #To start a shell + +insh help #For help ``` Snapshot @@ -26,7 +29,7 @@ It Works !!! TODO ========= --> Add A Shell +-> Add A Shell (Done) Note diff --git a/insh/insh.py b/insh/insh.py index 3a50840..2aa6ae9 100644 --- a/insh/insh.py +++ b/insh/insh.py @@ -6,7 +6,7 @@ import tempfile def color(text,colour='W'): - if os.name is 'nt': + if os.name == 'nt': colord={'W': 15,'B': 9,'G': 10,'C': 11,'R':12} if not colour in colord: colour='W' @@ -24,7 +24,15 @@ def help(): print("\n\nUsage: insh ") print("Author: SpeedX") -def main(): + +def createshell(): + import smartinput + color("Shell v1 Started. Made by Shivam (@shivamsn97)") + theshell = smartinput.Shell(callback=main, intitle=smartinput.Fore.GREEN+"$ "+smartinput.Style.RESET_ALL, outtitle="") + theshell.start() + + +def main(cmd = None, shell=None): messages = [ "You type like I drive.", "You speak an infinite deal of nothing", @@ -71,14 +79,18 @@ def main(): "It can only be attributed to human error.", "Did someone dropped you while you were a baby, eh?", "Take a stress pill and think things over."] - if len(sys.argv)==1: - help() + if len(sys.argv)==1 and not cmd: + createshell() exit() + if len(sys.argv) > 1: + if sys.argv[1] == "help": + help() + exit() try: - result = subprocess.run(sys.argv[1:],shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + result = subprocess.run(sys.argv[1:] if not cmd else cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) except: color(choice(messages)+"\n",'R') - color(sys.argv[1]+" : command not found",'B') + color(sys.argv[1] if not cmd else cmd+" : command not found",'B') exit() out = result.stdout.decode('utf-8') err = result.stderr.decode('utf-8') diff --git a/setup.py b/setup.py index b7f41a4..3004ebc 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name = 'insh', packages = ['insh'], - version = '1.1', + version = '1.2', description = 'Insults You When You Get An Error', long_description=long_description, long_description_content_type="text/markdown", @@ -15,6 +15,7 @@ download_url ="https://github.com/TheSpeedX/insh/archive/master.zip", keywords = ['shell','funny','insult','python'], data_files=[('', ['LICENSE'])], + install_requires=['smartinput'], classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers',