Skip to content

Commit

Permalink
[#3] Add ishell command
Browse files Browse the repository at this point in the history
https://github.com/open-craft-guild/blueberrypy

Add `ishell` command to blueberrypy CLI
  • Loading branch information
anxolerd authored and webknjaz committed Jun 28, 2017
1 parent db5dd11 commit 1895d1a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/blueberrypy/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import blueberrypy
from blueberrypy.config import BlueberryPyConfiguration
from blueberrypy.ishell import IShell
from blueberrypy.project import create_project
from blueberrypy.console import Console
from blueberrypy.template_engine import configure_jinja2
Expand Down Expand Up @@ -404,6 +405,43 @@ def console(**kwargs):
)).interact(banner)


def ishell(**kwargs):
"""
An IPYTHON REPL fully configured for experimentation.
usage:
blueberrypy ishell [options]
options:
-e ENVIRONMENT, --environment=ENVIRONMENT apply the given config environment
-C ENV_VAR_NAME, --env-var ENV_VAR_NAME add the given config from environment variable name
[default: BLUEBERRYPY_CONFIG]
-h, --help show this help message and exit """

banner = """
*****************************************************************************
* If the configuration file you specified contains a [sqlalchemy_engine*] *
* section, a default SQLAlchemy engine and session should have been created *
* for you automatically already. *
* Additionally all modules from your application package have been loaded *
* to globals() *
*****************************************************************************
"""

environment = kwargs.get("environment")
config_dir = kwargs.get("config_dir")
environment and cherrypy.config.update({"environment": environment})
configuration = BlueberryPyConfiguration(
config_dir=config_dir,
environment=environment,
env_var_name=kwargs.get('env_var'),
)
shell = IShell(configuration)
shell.show_banner(banner)
shell.mainloop()



def main():
"""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -445,6 +483,8 @@ def get_command_parser_and_callback(command):
doc, callback = create.__doc__, create
elif command == "console":
doc, callback = console.__doc__, console
elif command == "ishell":
doc, callback = ishell.__doc__, ishell
elif command == "bundle":
doc, callback = bundle.__doc__, bundle
elif command == "serve":
Expand Down

0 comments on commit 1895d1a

Please sign in to comment.