Merge pull request #1 from GlenRSmith/dev_scripts_command

Add a `scripts` command and a test for it.
This commit is contained in:
Glen Smith
2020-08-28 12:10:06 -06:00
committed by GitHub
2 changed files with 33 additions and 0 deletions
+20
View File
@@ -716,5 +716,25 @@ def clean(ctx, state, dry_run=False, bare=False, user=False):
system=state.system)
@cli.command(
short_help="Lists scripts in current environment config.",
context_settings=subcommand_context_no_interspersion,
)
@common_options
@argument("args", nargs=-1)
@pass_state
def scripts(state, args):
"""Lists scripts in current environment config."""
from ..core import project
if not project:
print("project not found")
exit(1)
scripts = project.parsed_pipfile.get('scripts', [])
print("command\tscript")
for k, v in scripts.items():
print(f"{k}\t{v}")
return
if __name__ == "__main__":
cli()
+13
View File
@@ -197,6 +197,19 @@ def test_bare_output(PipenvInstance):
assert p.pipenv('').out
@pytest.mark.cli
def test_scripts(PipenvInstance):
with PipenvInstance() as p:
with open(p.pipfile_path, "w") as f:
contents = """
[scripts]
pyver = "which python"
""".strip()
f.write(contents)
c = p.pipenv('scripts')
assert 'pyver' in c.out
@pytest.mark.cli
def test_help(PipenvInstance):
with PipenvInstance() as p: