Run Django management commands with a simple `dj {command_name}`. Can also use aliases for commands defined in a simple config file.
Project description
Why?
It is available everywhere if you install via pip
, has cute aliases defined in a JSON file (.dj-config.json
) per project, will run as many commands as you want, and defaults to Django management commands if an alias cannot be found.
Note that calling a long-running processes (e.g. runserver
) will prevent any other commands from being run.
Example .dj-config.json
{
"commands": [
{
"name": "m",
"help": "Does the migration dance",
"execute": "./manage.py makemigrations && ./manage.py migrate",
},
{
"name": "r",
"help": "Runserver",
"execute": "./manage.py runserver",
"long_running": true
}
]
}
Basic arguments and options
dj --help
to see all of the optionsdj --list
to see all of the available custom commandsdj {command_name}
to run a custom command or Django management command (e.g.dj migrate
)dj {command_name} --dry_run
to show what commands would run without actually executing them
How to work on the source
- Clone the repo
- Run the source locally:
poetry run python dj
- Test the source:
poetry run pytest
- Build and install locally:
poetry build && pip3 install --user --upgrade --force-reinstall dist/dj_command-0.1.0-py3-none-any.whl
- Test with
~/.local/bin/dj migrate
- Publish the source to pypi:
poetry publish --build --username USERNAME --password PASSWORD
Acknowledgements
- poetry: please, please, please continue to wrangle the complexity of 1) creating Python projects, and 2) installing dependencies; seriously, it's baffling out there without you
- click: ridiculously full-featured library to help implement CLI programs in Python; it has all the bells and most of the whistles
- attrs: would you like easy classes in Python? yes, please
- delegator.py: dealing with subprocess is a pain, but delegator hides all the ugly cruft behind a nice API
Prior art
This isn't a new idea and there are a few other implementations out there that do similar things. But, uh, I like mine. 😀
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dj-command-0.3.0.tar.gz
.
File metadata
- Download URL: dj-command-0.3.0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.6.6 Darwin/18.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aafc7fba3128cf24748306218f90a83733d4deb5d72933e14b902d851c18b740 |
|
MD5 | 273e0f53a8aefea87671309db247b4e0 |
|
BLAKE2b-256 | 6915294c2d9ebbadfbccbe6984c08e997d04c2c13191e4d55a173887b04fea16 |
File details
Details for the file dj_command-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: dj_command-0.3.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.6.6 Darwin/18.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52a24d4fd198d8ea73852b98d28a62d9f2aa92e59db2b7c4446c63d511b976f0 |
|
MD5 | 1763dfb04dc0a3b205b49084af5ca6b2 |
|
BLAKE2b-256 | 9687d612004939ace49e7b61fcf861e82c5261198a4c84e0fe6bf9064565cc79 |