ARGONAUTS 🧑🏽🚀
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
- Email, Password Support with validation
- Path Support with Autosuggestion
- 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()
Chaining Interactive Functions
Argonauts 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()
Email, Password, and Path Support
Argonauts provides built-in support for email, password, and path inputs with validation:
from argonauts import argonaut
from argonauts.inputs import Email, Password, Path
@argonaut(process_name="Please wait...")
def login(email: Email, password: Password):
"""Login with email and password."""
...
@argonaut(process_name="Loading Configurations...")
def configure(config_path: Path):
"""Load configurations from a file."""
...
You can customize these Input types by inhereting them and overriding the validate method:
from argonauts.inputs import Path
class JSONFile(Path):
def validate(self, value: str) -> bool:
return super().validate(value) and value.endswith(".json")
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for more details.
📄 License
Argonauts 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
Metadata
Release files for argonauts 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| argonauts-0.1.2.tar.gz | 5.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| argonauts-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.7 kB
Release files / argonauts-0.1.2.tar.gz
| Download URL | argonauts-0.1.2.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e78cd238c91c2e270f2916634b8dcd59d247a7e5d3c1da79a71fdacba8b3e6b6
|
|
BLAKE2b-256 checksum How to use checksums |
8ec96d8677c9e00ae6a2cd05b5c9d4d116fc111fbedfa133485fcfdc5feee03b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1024-azure
|
Release files / argonauts-0.1.2-py3-none-any.whl
| Download URL | argonauts-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
42c2b8bb40649757a24939972a52178700ee73382e8a289fd8f88e5ad90fc96d
|
|
BLAKE2b-256 checksum How to use checksums |
b6a1c09d53805d3c57d96da56205e2aa020f03d719a1709295525da0287b210f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1024-azure
|
Security for argonauts 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.