mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 14:50:16 +00:00
761a03d088
* Begin reviewing the basics docs. * Check in delta * More doc revisions. * Split apart basics docs. * Refactor based on building docs * add the files back as markdown. * more conversions to markdown. * more conversions to markdown. * fix markdown formatting. * convert index to markdown. * More docs review * More markdown and doc revisions. * Fix docs. * Update doc build requirements. * fix lint * Fix build with update/upgrade command. * remove useless quickstart and update the commands section. * Fix lint * change ordering of table of contents. * fix changelog duplicate headings. * Start splitting advanced topics. * minor nits * Move some sections from advanced to shell. * remove this section as its stale and kind of off topic. * move scripts out into its own section. * Wrap up revisions1 * fix lint * address PR feedback and other nits. * fix lint * Try improving ordering of table of contents, fix issue with indexes.md file location. * fix lint * PR feedback.
1.4 KiB
1.4 KiB
Custom Script Shortcuts
It is possible to create custom shortcuts in the optional [scripts] section of your Pipfile.
You can then run pipenv run <shortcut name> in your terminal to run the command in the
context of your pipenv virtual environment even if you have not activated the pipenv shell first.
For example, in your Pipfile:
[scripts]
printspam = "python -c \"print('I am a silly example, no one would need to do this')\""
---
toml
And then in your terminal:
$ pipenv run printspam
I am a silly example, no one would need to do this
Commands that expect arguments will also work.
[scripts]
echospam = "echo I am really a very silly example"
---
toml
Invoke script:
$ pipenv run echospam "indeed"
I am really a very silly example indeed
You can also specify pacakge functions as callables such as: <pathed.module>:<func>. These can also take arguments.
For example:
[scripts]
my_func_with_args = {call = "package.module:func('arg1', 'arg2')"}
my_func_no_args = {call = "package.module:func()"}
To run the script:
$ 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.
$ pipenv scripts
command script
echospam echo I am really a very silly example