Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI (work in progress) #72

Merged
merged 2 commits into from
Oct 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions responder/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
"""Responder.

Usage:
responder
responder run [--build] [--debug] <module>
responder build
responder --version

Options:
-h --help Show this screen.
-v --version Show version.

"""

import os

import docopt
from .__version__ import __version__


def cli():
args = docopt.docopt(
__doc__, argv=None, help=True, version=__version__, options_first=False
)

module = args["<module>"]
build = args["build"] or args["--build"]
run = args["run"]

if build:
os.system("npm build")

if run:
split_module = module.split(":")

if len(split_module) > 1:
module = split_module[0]
prop = split_module[1]
else:
prop = "api"

app = __import__(module)
getattr(app, prop).run()
1 change: 1 addition & 0 deletions responder/core.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from .api import API
from .models import Request, Response
from .cli import cli
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ def run(self):
author_email="[email protected]",
url="https://github.com/kennethreitz/responder",
packages=find_packages(exclude=["tests"]),
# entry_points={
# "console_scripts": ["responder=responder:cli"]
# },
entry_points={"console_scripts": ["responder=responder:cli"]},
package_data={
# "": ["LICENSE", "NOTICES"],
# "pipenv.vendor.requests": ["*.pem"],
Expand Down