Merge pull request #5396 from jerempy/Update-docs-for-script-calls

Update documentation for callable scripts
This commit is contained in:
Oz N Tiram
2022-10-12 11:08:35 +02:00
committed by GitHub
3 changed files with 18 additions and 2 deletions
+14 -1
View File
@@ -581,7 +581,20 @@ For example:
$ pipenv run echospam "indeed"
I am really a very silly example indeed
You can then display the names and commands of your shortcuts by running ``pipenv scripts`` in your terminal.
You can also specify pacakge functions as callables such as: ``<pathed.module>:<func>``. These can also take arguments.
For exaple:
.. code-block:: toml
[scripts]
my_func_with_args = {call = "package.module:func('arg1', 'arg2')"}
my_func_no_args = {call = "package.module:func()"}
::
$ pipenv run my_func_with_args
$ pipenv run my_func_no_args
You can display the names and commands of your shortcuts by running ``pipenv scripts`` in your terminal.
::
+1
View File
@@ -0,0 +1 @@
Update pipenv docs for with example for callabale package functions in Pipfile scripts
+3 -1
View File
@@ -32,7 +32,9 @@ def _parse_toml_inline_table(value: tomlkit.items.InlineTable) -> str:
if cmd_key == "call":
module, _, func = str(value["call"]).partition(":")
if not module or not func:
raise ScriptParseError("Callable must be like: <pathed.module>:<func>")
raise ScriptParseError(
"Callable must be like: name = {call = \"package.module:func('arg')\"}"
)
if re.search(r"\(.*?\)", func) is None:
func += "()"
return f'python -c "import {module} as _m; _m.{func}"'