-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Chandra Irugalbandara
committed
Jul 28, 2024
1 parent
0acd659
commit 1f072c7
Showing
11 changed files
with
304 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Linting and Pre-commit checks | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.10 | ||
|
||
- name: Install pre-commit | ||
run: pip install pre-commit | ||
|
||
- name: Run pre-commit hooks | ||
run: pre-commit run --all-files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: PyPI Release | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
- name: Install Poetry | ||
run: | | ||
pip install poetry | ||
- name: Build package | ||
run: poetry build | ||
- name: Publish package | ||
run: | | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | ||
poetry publish | ||
continue-on-error: true | ||
- run: pip install githubrelease markdown-to-json | ||
- run: python scripts/gh_release.py | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# RELEASES | ||
|
||
## `0.1.0` - 2024-07-28 | ||
- [INIT] Working Initial Version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Contributing Guidelines | ||
|
||
Thank you for your interest in contributing to our project! To ensure a smooth collaboration, please follow the steps below: | ||
|
||
1. **Create an Issue**: Before starting any work, please create an issue to discuss the changes you plan to make. This allows for better coordination and avoids duplication of efforts. | ||
|
||
2. **Create a Pull Request**: Once you have identified the changes you want to make, fork the repository and create a new branch for your changes. Make your modifications and submit a pull request (PR) to the main repository. | ||
|
||
3. **Do Your Thing**: Implement your changes according to the project's guidelines and coding standards. Ensure that your code is well-documented and follows best practices. | ||
|
||
4. **Run Pre-commit Hooks**: Before submitting your PR, run the pre-commit hooks to ensure that your code adheres to the project's formatting and style guidelines. This helps maintain consistency across the codebase. | ||
|
||
5. **Run Tests**: It is essential to run the project's tests to verify that your changes do not introduce any regressions or break existing functionality. Make sure all tests pass successfully before submitting your PR. | ||
|
||
6. **Maintainer Review and Merge**: Once your PR is submitted, a project maintainer will review your changes. They may provide feedback or request further modifications. Once approved, your changes will be merged into the main repository. | ||
|
||
We appreciate your contributions and look forward to working with you! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,132 @@ | ||
# argonauts | ||
<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/) | ||
</div> | ||
|
||
--- | ||
|
||
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: | ||
|
||
```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() | ||
``` | ||
|
||
[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: | ||
|
||
```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() | ||
``` | ||
|
||
[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](CONTRIBUTING.md) for more details. | ||
|
||
## 📄 License | ||
|
||
Astrolink 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
"""Argonauts: Easy Interactive or Non-Interactive CLI Arguments.""" | ||
|
||
from argonauts.decorators import interactive, LogBook | ||
from argonauts.decorators import LogBook, argonaut | ||
|
||
__all__ = ["interactive", "LogBook"] | ||
__all__ = ["argonaut", "LogBook"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.