Created
July 5, 2016 01:14
-
-
Save josegomezr/03cb03a25b95c839daeecbd3c7e98a1c to your computer and use it in GitHub Desktop.
cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from code import InteractiveConsole | |
import sys | |
import readline | |
import textwrap | |
sys.ps1 = "--> " | |
sys.ps2 = " " | |
class DiggiCLI(InteractiveConsole): | |
def raw_input(self, prompt): | |
return input(prompt) | |
def compile(self, source): | |
# si la entrada (source): | |
# * esta incompleta -> return True | |
# sino | |
# * hay error: suelta el traceback | |
# * ta buena: imprime el resultado | |
# return False | |
print("Compilando") | |
return False | |
def runsource(self, source, *args): | |
return self.compile(source) | |
if __name__ == '__main__': | |
sh = DiggiCLI() | |
python_version = ('.'.join(( str(i) for i in sys.version_info[0:3] ))) | |
diggi_version = '0.0.1' | |
banner = '''\ | |
Python {0} | |
Diggi CLI {1}\ | |
'''; | |
banner = banner.format(python_version, diggi_version) | |
banner = textwrap.dedent(banner) | |
sh.interact(banner=banner) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment