Skip to content

Commit

Permalink
Refactor: Mirgrated to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
HYP3R00T committed Sep 10, 2024
1 parent 6e10242 commit 30bfe8a
Show file tree
Hide file tree
Showing 21 changed files with 1,626 additions and 244 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/mkdocs_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: MkDocs Publish

on:
push:
branches:
- main # Change this to your main branch name

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install --no-root
- name: Build and deploy
run: |
poetry run mkdocs build --verbose
poetry run mkdocs gh-deploy --verbose --force
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions .github/workflows/pypi_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: PyPI Publish

on:
push:
branches:
- main # Change this to your main branch name

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Install dependencies
run: |
poetry install --no-root
- name: Build and publish
env:
POETRY_PYPI_TOKEN: ${{ secrets.POETRY_PYPI_TOKEN }}
run: |
poetry version patch
poetry build
poetry publish --username __token__ --password $POETRY_PYPI_TOKEN
- name: Commit version change
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add pyproject.toml
git commit -m "Bump version to $(poetry version --short)"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
156 changes: 154 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,162 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
.vscode/
.vscode
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
exclude: mkdocs.yml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/python-poetry/poetry
rev: "1.8.3"
hooks:
- id: poetry-check
- repo: local
hooks:
- id: ruff
name: ruff
entry: poetry run ruff check . --fix
language: system
types: [python]
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"markdownlint.config": {
"MD033": {
"allowed_elements": [
"iframe",
"a",
"h1",
"p",
"img",
]
}
}
}
4 changes: 2 additions & 2 deletions Example.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# import hypercli
from hypercli import hypercli
from hypercli import Hypercli

# create an instance of hypercli
cli = hypercli()
cli = Hypercli()

# configure the instance
cli.config["banner_text"] = "HYPERCLI"
Expand Down
86 changes: 10 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
```
_ _ _
| | | (_)
| |__ _ _ _ __ ___ _ __ ___| |_
| '_ \| | | | '_ \ / _ \ '__/ __| | |
| | | | |_| | |_) | __/ | | (__| | |
|_| |_|\__, | .__/ \___|_| \___|_|_|
__/ | |
|___/|_| v 1.0.1
```
<h1 align="center">hypercli</h1>

# hypercli
<p align="center">
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/HYP3R00T/hypercli/pypi_publish.yml?style=for-the-badge&labelColor=%2324273a&color=%23b7bdf8">
<a src="https://pypi.org/project/hypercli/" target="_blank">
<img alt="Pypi versions" src="https://img.shields.io/pypi/v/hypercli?style=for-the-badge&labelColor=%2324273a&color=%23b7bdf8">
</a>
</p>

**hypercli** is a Python package that provides an elegant solution for interacting with command line tools. It offers a menu-based command line interface (CLI) that allows users to navigate through different options and execute functions based on their choices.

Expand All @@ -23,76 +19,14 @@

You can install **hypercli** using pip. Open your terminal and run the following command:

```
```bash
pip install hypercli
```

## Usage

To use **hypercli**, import the `hypercli` module from the `hypercli` package and create an instance of the `hypercli` class. You can then define your menus, options, and functions to be executed. Finally, call the `run()` method to start the CLI interface.

Use the [Wiki](docs/Wiki.md) for more information on the configs, methods, and resources available in **hypercli**.

Here's an example of how to use **hypercli**:

```python
# import hypercli
from hypercli import hypercli

# create an instance of hypercli
cli = hypercli()

# configure the instance
cli.config["banner_text"] = "HYPERCLI"
cli.config["intro_title"] = "Intro"
cli.config["intro_content"] = "Generate enhanced menu-driven CLI programs with ease!"
cli.config["show_menu_table_header"] = True

# add navigation options to the menu
cli.link("Main Menu", "Mathematics Menu")
cli.link("Main Menu", "String Menu")


@cli.entry(menu="Main Menu", option="Greeter")
def greet():
name = input("Enter your name: ")
print(f"Hello, {name}!")


@cli.entry(menu="Mathematics Menu", option="Add two numbers")
def add(num1=1, num2=1):
a = int(input(f"Enter first number (default {num1}): ") or num1)
b = int(input(f"Enter second number (default {num2}): ") or num2)
print(f"{a} + {b} = {a + b}")


@cli.entry(menu="Mathematics Menu", option="Subtract two numbers")
def sub(num1=1, num2=1):
a = int(input(f"Enter first number (default {num1}): ") or num1)
b = int(input(f"Enter second number (default {num2}): ") or num2)
print(f"{a} - {b} = {a - b}")


@cli.entry(menu="String Menu", option="Reverse a string")
def reverse():
string = input("Enter a string: ")
print(string[::-1])


@cli.entry(menu="String Menu", option="Show length of a string")
def str_length():
string = input("Enter a string: ")
print(f"Length of string is {len(string)}")


# run the cli
cli.run()

```

![](docs/assests/example_demo.gif)

Checkout [documentation](https://hypercli.hyperoot.dev) for more information on the configs, methods, and resources available in **hypercli**.

## License

This project is licensed under the MIT License. See the [MIT](https://choosealicense.com/licenses/mit/) file for more information.
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hypercli.hyperoot.dev
Loading

0 comments on commit 30bfe8a

Please sign in to comment.