mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #1 from GlenRSmith/dev_scripts_command
Add a `scripts` command and a test for it.
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user