Add main CLI function, shows version and homepage

This commit is contained in:
rlaphoenix 2022-07-20 14:44:20 +01:00
parent 36c83268c3
commit 2701c7dcd0
1 changed files with 25 additions and 0 deletions

25
pywidevine/main.py Normal file
View File

@ -0,0 +1,25 @@
import logging
from datetime import datetime
import click
from pywidevine import __version__
@click.group(invoke_without_command=True)
@click.option("-v", "--version", is_flag=True, default=False, help="Print version information.")
@click.option("-d", "--debug", is_flag=True, default=False, help="Enable DEBUG level logs.")
def main(version: bool, debug: bool) -> None:
"""pywidevine—Python Widevine CDM implementation."""
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)
log = logging.getLogger()
copyright_years = 2022
current_year = datetime.now().year
if copyright_years != current_year:
copyright_years = f"{copyright_years}-{current_year}"
log.info(f"pywidevine version {__version__} Copyright (c) {copyright_years} rlaphoenix")
log.info("https://github.com/rlaphoenix/pywidevine")
if version:
return