argonauts


Nameargonauts JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryEasily convert function to interactive command line applications
upload_time2024-07-29 16:48:55
maintainerNone
docs_urlNone
authorChandra Irugalbandara
requires_python<4.0,>=3.10
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center">

  # ARGONAUTS 🧑🏽‍🚀

  [![PyPI version](https://badge.fury.io/py/argonauts.svg)](https://badge.fury.io/py/argonauts)
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
  [![Python Versions](https://img.shields.io/pypi/pyversions/argonauts.svg)](https://pypi.org/project/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.

![Argonauts Demo](public/demo_0.gif)

</div>

## 🚀 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:

```bash
pip install argonauts
```

Install from source:

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

## 🛠 Usage

### Basic Usage

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

```python
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:

```python
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()
```

![Argonauts Demo](public/demo_1.gif)

### Email, Password, and Path Support

Argonauts provides built-in support for email, password, and path inputs with validation:

```python
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."""
    ...
```
![Argonauts Demo](public/demo_2.gif)

You can customize these Input types by inhereting them and overriding the `validate` method:

```python
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](CONTRIBUTING.md) for more details.

## 📄 License

Argonauts is released under the MIT License. See the [LICENSE](LICENSE) file for details.

## 🙏 Acknowledgements

- [Questionary](https://github.com/tmbo/questionary) for providing an excellent prompt library
- [Rich](https://github.com/Textualize/rich) for beautiful and interactive terminal output

---

<div align="right">
  Made with ❤️ for the Developers by the Developers
</div>
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "argonauts",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Chandra Irugalbandara",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/8e/c9/6d8677c9e00ae6a2cd05b5c9d4d116fc111fbedfa133485fcfdc5feee03b/argonauts-0.1.2.tar.gz",
    "platform": null,
    "description": "<div align=\"center\">\n\n  # ARGONAUTS \ud83e\uddd1\ud83c\udffd\u200d\ud83d\ude80\n\n  [![PyPI version](https://badge.fury.io/py/argonauts.svg)](https://badge.fury.io/py/argonauts)\n  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n  [![Python Versions](https://img.shields.io/pypi/pyversions/argonauts.svg)](https://pypi.org/project/argonauts/)\n\n\n---\n\nArgonauts 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.\n\n![Argonauts Demo](public/demo_0.gif)\n\n</div>\n\n## \ud83d\ude80 Features\n\n- Transform functions into interactive CLIs with a single decorator\n- Automatic type inference and validation\n- Email, Password Support with validation\n- Path Support with Autosuggestion\n- Chainable interactive functions\n\n## \ud83d\udce6 Installation\n\nInstall Argonauts using pip:\n\n```bash\npip install argonauts\n```\n\nInstall from source:\n\n```bash\ngit clone <repo-url>\ncd argonauts\npip install .\n```\n\n## \ud83d\udee0 Usage\n\n### Basic Usage\n\nHere's a simple example of how to use Argonaut:\n\n```python\nfrom argonauts import argonaut\nfrom enum import Enum\n\nclass PizzaSize(Enum):\n    SMALL = \"Small\"\n    MEDIUM = \"Medium\"\n    LARGE = \"Large\"\n\nclass Topping(Enum):\n    PEPPERONI = \"Pepperoni\"\n    MUSHROOMS = \"Mushrooms\"\n    ONIONS = \"Onions\"\n    SAUSAGE = \"Sausage\"\n    BELL_PEPPERS = \"Bell Peppers\"\n\n\n@argonaut(process_name=\"We are making your pizza! Keep calm!\")\ndef order_pizza(\n    size: PizzaSize,\n    toppings: list[Topping],\n    extra_cheese: bool = False,\n    delivery: bool = True,\n):\n    \"\"\"Order a delicious pizza with your favorite toppings.\"\"\"\n    pizza = f\"{size.value} pizza with {', '.join(t.value for t in toppings)}\"\n    if extra_cheese:\n        pizza += \" and extra cheese\"\n    print(f\"You've ordered: {pizza}\")\n\n    time.sleep(20)  # Simulate making the pizza\n\n    if delivery:\n        print(\"Your pizza will be delivered soon!\")\n    else:\n        print(\"Your pizza is ready for pickup!\")\n\norder_pizza()\n```\n\n### Chaining Interactive Functions\n\nArgonauts allows you to chain multiple interactive functions with the ability to share the previous arguments:\n\n```python\nfrom argonauts import argonaut, LogBook\n\nargs = LogBook()\n\n@argonaut(logbook=args)\ndef select_movie(title: str, genre: str):\n    rating = some_fn_to_get_rating(title)\n    return {\"title\": title, \"rating\": rating}\n\n@argonaut(logbook=args, include_params=[\"popcorn\", \"drinks\"]) # Include only the specified parameters\ndef select_snacks(movie: dict, genre: str, popcorn: bool, drinks: list[Drinks]):\n    print(f\"Watching {args.title} ({movie['rating']} stars)\") # Reuse the title argument\n    print(\"Genre:\", genre)\n    if popcorn:\n        print(\"- Popcorn\")\n    print(f\"- Drinks: {', '.join(drinks)}\")\n\ndef movie_night():\n    movie = select_movie()\n    select_snacks(movie=movie, genre=args.genre) # Reuse the genre argument\n\nmovie_night()\n```\n\n![Argonauts Demo](public/demo_1.gif)\n\n### Email, Password, and Path Support\n\nArgonauts provides built-in support for email, password, and path inputs with validation:\n\n```python\nfrom argonauts import argonaut\nfrom argonauts.inputs import Email, Password, Path\n\n@argonaut(process_name=\"Please wait...\")\ndef login(email: Email, password: Password):\n    \"\"\"Login with email and password.\"\"\"\n    ...\n\n@argonaut(process_name=\"Loading Configurations...\")\ndef configure(config_path: Path):\n    \"\"\"Load configurations from a file.\"\"\"\n    ...\n```\n![Argonauts Demo](public/demo_2.gif)\n\nYou can customize these Input types by inhereting them and overriding the `validate` method:\n\n```python\nfrom argonauts.inputs import Path\n\nclass JSONFile(Path):\n    def validate(self, value: str) -> bool:\n        return super().validate(value) and value.endswith(\".json\")\n```\n\n## \ud83e\udd1d Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for more details.\n\n## \ud83d\udcc4 License\n\nArgonauts is released under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## \ud83d\ude4f Acknowledgements\n\n- [Questionary](https://github.com/tmbo/questionary) for providing an excellent prompt library\n- [Rich](https://github.com/Textualize/rich) for beautiful and interactive terminal output\n\n---\n\n<div align=\"right\">\n  Made with \u2764\ufe0f for the Developers by the Developers\n</div>",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easily convert function to interactive command line applications",
    "version": "0.1.2",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b6a1c09d53805d3c57d96da56205e2aa020f03d719a1709295525da0287b210f",
                "md5": "2fe049186aca72b5ab467bb4905f74e6",
                "sha256": "42c2b8bb40649757a24939972a52178700ee73382e8a289fd8f88e5ad90fc96d"
            },
            "downloads": -1,
            "filename": "argonauts-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fe049186aca72b5ab467bb4905f74e6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 6343,
            "upload_time": "2024-07-29T16:48:54",
            "upload_time_iso_8601": "2024-07-29T16:48:54.655856Z",
            "url": "https://files.pythonhosted.org/packages/b6/a1/c09d53805d3c57d96da56205e2aa020f03d719a1709295525da0287b210f/argonauts-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ec96d8677c9e00ae6a2cd05b5c9d4d116fc111fbedfa133485fcfdc5feee03b",
                "md5": "fba1216aada2fa635d38b6c14f3b0da6",
                "sha256": "e78cd238c91c2e270f2916634b8dcd59d247a7e5d3c1da79a71fdacba8b3e6b6"
            },
            "downloads": -1,
            "filename": "argonauts-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "fba1216aada2fa635d38b6c14f3b0da6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 5335,
            "upload_time": "2024-07-29T16:48:55",
            "upload_time_iso_8601": "2024-07-29T16:48:55.924935Z",
            "url": "https://files.pythonhosted.org/packages/8e/c9/6d8677c9e00ae6a2cd05b5c9d4d116fc111fbedfa133485fcfdc5feee03b/argonauts-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-29 16:48:55",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "argonauts"
}
        
Elapsed time: 1.06476s