Skip to content

Commit

Permalink
Add a scripts command and a test for it.
Browse files Browse the repository at this point in the history
  • Loading branch information
GlenRSmith committed Aug 28, 2020
1 parent 7a7100e commit 07d166a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 13 additions & 0 deletions tests/integration/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 07d166a

Please sign in to comment.