Skip to main content

Easily convert function to interactive command line applications

Project description

ARGONAUTS 🧑🏽‍🚀

PyPI version License: MIT Python Versions


Argonauts is a Python library that transforms your functions into interactive command-line interfaces with ease. Using simple decorators, you can create engaging CLI experiences without the hassle of manual argument parsing.

🚀 Features

  • Transform functions into interactive CLIs with a single decorator
  • Automatic type inference and validation
  • Chainable interactive functions

📦 Installation

Install Argonauts using pip:

pip install argonauts

Install from source:

git clone <repo-url>
cd argonauts
pip install .

🛠 Usage

Basic Usage

Here's a simple example of how to use Argonaut:

from argonauts import argonaut
from enum import Enum

class PizzaSize(Enum):
    SMALL = "Small"
    MEDIUM = "Medium"
    LARGE = "Large"

class Topping(Enum):
    PEPPERONI = "Pepperoni"
    MUSHROOMS = "Mushrooms"
    ONIONS = "Onions"
    SAUSAGE = "Sausage"
    BELL_PEPPERS = "Bell Peppers"


@argonaut(process_name="We are making your pizza! Keep calm!")
def order_pizza(
    size: PizzaSize,
    toppings: list[Topping],
    extra_cheese: bool = False,
    delivery: bool = True,
):
    """Order a delicious pizza with your favorite toppings."""
    pizza = f"{size.value} pizza with {', '.join(t.value for t in toppings)}"
    if extra_cheese:
        pizza += " and extra cheese"
    print(f"You've ordered: {pizza}")

    time.sleep(20)  # Simulate making the pizza

    if delivery:
        print("Your pizza will be delivered soon!")
    else:
        print("Your pizza is ready for pickup!")

order_pizza()

[GIF placeholder: Show the code snippet side-by-side with a GIF of the resulting interactive CLI]

Chaining Interactive Functions

Astrolink allows you to chain multiple interactive functions with the ability to share the previous arguments:

from argonauts import argonaut, LogBook

args = LogBook()

@argonaut(logbook=args)
def select_movie(title: str, genre: str):
    rating = some_fn_to_get_rating(title)
    return {"title": title, "rating": rating}

@argonaut(logbook=args, include_params=["popcorn", "drinks"]) # Include only the specified parameters
def select_snacks(movie: dict, genre: str, popcorn: bool, drinks: list[Drinks]):
    print(f"Watching {args.title} ({movie['rating']} stars)") # Reuse the title argument
    print("Genre:", genre)
    if popcorn:
        print("- Popcorn")
    print(f"- Drinks: {', '.join(drinks)}")

def movie_night():
    movie = select_movie()
    select_snacks(movie=movie, genre=args.genre) # Reuse the genre argument

movie_night()

[GIF placeholder: Show the code snippet side-by-side with a GIF of the resulting chained interactive CLI]

🤝 Contributing

We welcome contributions! Please see our Contributing Guide for more details.

📄 License

Astrolink is released under the MIT License. See the LICENSE file for details.

🙏 Acknowledgements

  • Questionary for providing an excellent prompt library
  • Rich for beautiful and interactive terminal output

Made with ❤️ for the Developers by the Developers

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

argonauts-0.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

argonauts-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file argonauts-0.1.0.tar.gz.

File metadata

  • Download URL: argonauts-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1024-azure

File hashes

Hashes for argonauts-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4123cfb5554ef58db6a1f7b4dd94d5ecf838f2d03d99e8e8ff634e578b958182
MD5 8b07f3cf01f42b9779b743c41a3c6938
BLAKE2b-256 36d888a3a501bde562bc66b94eb071f840ec4eb373f0ea4f00e96a2e891c325b

See more details on using hashes here.

File details

Details for the file argonauts-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: argonauts-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1024-azure

File hashes

Hashes for argonauts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 642efbcd21821d0ecb15bb72a5a1de4b6937702b06b1f7f570cbc3b1c5876067
MD5 438f9d60097a74f32af6b56f268fe5c0
BLAKE2b-256 85889891ac580e3f032d0f69c8f7c2a27e9cddb22f5c6535f930dff87420e985

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