Skip to main content

Scrunkly

Scrunkly is a lightweight Python utility for defining and running scripts through a flexible command-line interface. It allows users to organize commonly used scripts into an easily maintainable dictionary, making script execution and management simpler.

Features

  • Script Management: Define scripts in a dictionary and run them via command line.
  • Sub-Scripts: Chain scripts together and run them in sequence.
  • Error Handling: Detect self-referencing scripts and prevent infinite loops.
  • Flexible Scripting: Supports both string-based and callable scripts.

Installation

You can install the required dependencies with pipenv:

pip install scrunkly

Usage

Define your scripts in a dictionary and pass it to scrunkly.scripts. You can map script names to shell commands or Python functions. Sub-scripts are supported, allowing a script to trigger other scripts in the map.

Here's an example usage:

# run.py
from scrunkly import scripts, py

def get_available_port() -> int:
    ...

def instructions():
    ...

scripts({
    "api:prod": f"{py} -m uvicorn api:app --host 0.0.0.0 --port {get_available_port()}",
    "api:dev": f"{py} -m uvicorn api:app --reload",
    "worker": f"{py} worker-runner.py",
    "install": f"{py} -m pipenv install",
    "mongo:dev": "docker run -d --name api-dev -p 27017:27017 mongo",
    "data-import": f"{py} ./scripts/part_data_import.py",
    "setup:dev": ["mongo:dev", "data-import", instructions],
})

Running a Script

You can run a script by providing its name as a command-line argument:

python run.py api:dev

This will execute the corresponding script, such as starting the API in development mode using Uvicorn.

Chaining Scripts

You can chain multiple scripts together using a list of script names. For example, the setup:dev script runs two scripts: mongo:dev and data-import:

python run.py setup:dev

Contributing

Feel free to fork this repository and submit pull requests. Contributions are welcome!

License

This project is licensed under the MIT License.


Happy scripting with Scrunkly!

Release files for scrunkly 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for scrunkly 0.1.3
File Size Uploaded
scrunkly-0.1.3.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for scrunkly 0.1.3
File Interpreter ABI Platform
scrunkly-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.6 kB

Release files / scrunkly-0.1.3.tar.gz

Download URL scrunkly-0.1.3.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b09606b499d20bb76be5ea8fbb6416016dfe34d2e8e1a11a003f85065354903e
BLAKE2b-256 checksum
How to use checksums
bdf3ad26f54e5de6a71d85a9ffaaae5165a1cef36de3dbff6c60089ac1cda194
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / scrunkly-0.1.3-py3-none-any.whl

Download URL scrunkly-0.1.3-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a36f29c4dc939b699e791a074fa67f477e6e3e2354489f5a1dcaf8038ddff552
BLAKE2b-256 checksum
How to use checksums
322053629746d92d0a192cb78959b464ed15b1f1664ff67faa16d704af997607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page