-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68bbea0
commit 5be3422
Showing
5 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""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, version=__version__, options_first=False) | ||
|
||
module = args["<module>"] | ||
build = args["build"] or args["--build"] | ||
run = args["run"] | ||
|
||
if build: | ||
os.system("npm run build") # noqa: S605, S607 | ||
|
||
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() |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import subprocess | ||
|
||
import pytest | ||
|
||
from responder.__version__ import __version__ | ||
|
||
pytest.importorskip("docopt", reason="docopt-ng package not installed") | ||
|
||
|
||
def test_cli_version(capfd): | ||
subprocess.check_call(["responder", "--version"]) # noqa: S603, S607 | ||
stdout = capfd.readouterr().out.strip() | ||
assert stdout == __version__ |