Skip to content

Instantly share code, notes, and snippets.

@josegomezr
Created July 5, 2016 01:14
Show Gist options
  • Save josegomezr/03cb03a25b95c839daeecbd3c7e98a1c to your computer and use it in GitHub Desktop.
Save josegomezr/03cb03a25b95c839daeecbd3c7e98a1c to your computer and use it in GitHub Desktop.
cli
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