feat: add cli script

This commit is contained in:
2022-10-04 02:14:44 -03:00
parent 505ce8308f
commit 017ea4f354
5 changed files with 36 additions and 4 deletions

View File

@@ -1,3 +1,3 @@
__version__ = "0.1.0" __version__ = "0.1.1"
from .client import PPGEE from .client import PPGEE

30
ppgee/__main__.py Normal file
View File

@@ -0,0 +1,30 @@
import argparse
import asyncio
from . import PPGEE
def get_args():
parser = argparse.ArgumentParser(description="Confirm your montly PPGEE attendency")
parser.add_argument("username", type=str, help="Your PPGEE's username")
parser.add_argument("password", type=str, help="Your PPGEE's password")
return parser.parse_args()
async def cli():
args = get_args()
user, password = args.username, args.password
async with PPGEE(user=user, password=password) as ppgee:
frequency_page = await ppgee.frequency()
await asyncio.sleep(1)
if frequency_page.is_available():
print("Attendency confirmed.")
await frequency_page.confirm()
else:
print("Attendency not available yet.")
await asyncio.sleep(1)
def main():
asyncio.run(cli())
if __name__ == "__main__":
main()

View File

@@ -10,7 +10,6 @@ logger = logging.getLogger(__name__)
def is_logged_check(method): def is_logged_check(method):
@wraps(method) @wraps(method)
def wrapper(self, *args, **kwargs): def wrapper(self, *args, **kwargs):
print("checking if logged in", self.is_logged)
if not self.is_logged: if not self.is_logged:
raise Exception("You must be logged in to use this method") raise Exception("You must be logged in to use this method")
return method(self, *args, **kwargs) return method(self, *args, **kwargs)

View File

@@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "ppgee" name = "ppgee"
version = "0.1.0" version = "0.1.1"
description = "" description = ""
authors = ["tiagovla <tiagovla@gmail.com>"] authors = ["tiagovla <tiagovla@gmail.com>"]
@@ -13,6 +13,9 @@ beautifulsoup4 = "^4.11.1"
pytest = "^5.2" pytest = "^5.2"
sendgrid = "^6.9.7" sendgrid = "^6.9.7"
[tool.poetry.scripts]
ppgee = "ppgee.__main__:main"
[build-system] [build-system]
requires = ["poetry-core>=1.0.0"] requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"

View File

@@ -2,4 +2,4 @@ from ppgee import __version__
def test_version(): def test_version():
assert __version__ == '0.1.0' assert __version__ == "0.1.1"