Skip to main content

A script runner for the modern age.

Project description

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

Ensure that Python is installed on your machine. Scrunkly will attempt to automatically detect the correct Python executable (e.g., python, python3, or py).

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

scripts({
    "api:prod": f"{py} -m uvicorn api:app --host 0.0.0.0",
    "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"],
})

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

Error Handling

Scrunkly ensures that scripts do not reference themselves, preventing infinite loops. If a script attempts to call itself, an error will be raised:

Exception: Cannot call self-referencing script

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!

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

scrunkly-0.0.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

scrunkly-0.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file scrunkly-0.0.1.tar.gz.

File metadata

  • Download URL: scrunkly-0.0.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for scrunkly-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e9caa4f57d5fcc17084a7161459963f9b6832bfd3f36e5eacddcd058976622bb
MD5 11736b638fcdf7d1d0ffa16d0e6e00f0
BLAKE2b-256 2d0ccf89984268694f58d6c8ceecb9b108c126d332c288174dcd1d5eb1a548cd

See more details on using hashes here.

File details

Details for the file scrunkly-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: scrunkly-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for scrunkly-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0cab064ddf1aa546e5e1af26147f8b47719e829a34ea71d63bd5afc09fcd7a9b
MD5 595c11da4edcd7a35f05dbe41ded18b6
BLAKE2b-256 6babb3e7e3cc2ce859d2b18470ace37ba161a9288ecc9ed4849327f8c9d69ec4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page