Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aahnik committed Jun 11, 2021
1 parent 7e51960 commit 2fce97d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 12 deletions.
18 changes: 17 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tg-login = "^0.0.2"
pytesseract = "^0.3.7"
rich = "^10.3.0"
pyfiglet = "^0.8.post1"
verlat = "^0.1.0"

[tool.poetry.dev-dependencies]
typer-cli = "^0.0.11"
Expand Down
38 changes: 27 additions & 11 deletions tgcf/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import typer
from dotenv import load_dotenv
from pyfiglet import Figlet
from rich import traceback
from rich import print, traceback
from rich.logging import RichHandler
from verlat import latest_release

from tgcf import __version__

Expand All @@ -22,20 +23,20 @@
app = typer.Typer(add_completion=False)


def topper():
fig = Figlet(font="speed")
print(fig.renderText("tgcf"))
version_check()
print("\n\n")


class Mode(str, Enum):
"""tgcf works in two modes."""

PAST = "past"
LIVE = "live"


def version_callback(value: bool):
"""Show current version and exit."""
if value:
print(__version__)
raise typer.Exit()


def verbosity_callback(value: bool):
"""Set logging level."""
traceback.install()
Expand All @@ -53,9 +54,7 @@ def verbosity_callback(value: bool):
)
],
)
fig = Figlet(font="speed")
print(fig.renderText("tgcf"))

topper()
logging.info("Verbosity turned on! This is suitable for debugging")
nl = "\n"
logging.info(
Expand All @@ -67,6 +66,23 @@ def verbosity_callback(value: bool):
)


def version_callback(value: bool):
"""Show current version and exit."""

if value:
print(__version__)
raise typer.Exit()


def version_check():
latver = latest_release("tgcf").version
if __version__ != latver:
print(
f"tgcf has a newer release {latver} availaible!\
\nVisit http://bit.ly/update-tgcf"
)


@app.command()
def main(
mode: Mode = typer.Argument(
Expand Down

0 comments on commit 2fce97d

Please sign in to comment.