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

Add a scripts command and a test for it. #1

Merged
merged 1 commit into from
Aug 28, 2020
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
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