Closed github-actions[bot] closed 1 year ago
Add global option to hide banner
https://github.com/in03/Resolve-Proxy-Encoder/blob/9530708e7238af5a004eff6cd54b66014c52e791/resolve_proxy_encoder/app/cli.py#L23
#!/usr/bin/env python3.6 import logging import subprocess import webbrowser from pathlib import Path from typing import Optional import typer from merge_args import merge_args from pyfiglet import Figlet from rich import print from rich.console import Console from rich.prompt import Confirm from rich.rule import Rule from .utils import pkg_info # Init classes cli_app = typer.Typer() console = Console() # TODO: Add global option to hide banner # labels: enhancement hide_banner = typer.Option( default=False, help="Hide the title and build info on startup" ) # Special functions @cli_app.callback(invoke_without_command=True) def draw_banner(): # Print CLI title fig = Figlet() text = fig.renderText("Resolve Proxy Encoder") print(f"[green]{text}\n") # Get build info build_info = pkg_info.get_build_info("Resolve-Proxy-Encoder") # Get VC key vc_key_file = Path(__file__).parent.parent.parent.joinpath("version_constraint_key") with open(vc_key_file) as file: vc_key = file.read() # Print banner data if build_info["build"] == "release": print( f"[bold]{str(build_info['build']).capitalize()} build[/] " f"{build_info['version']} | " f"[bold]VC key:[/] '{vc_key}'" ) else: print( f"[bold]{str(build_info['build']).capitalize()} build[/] " f"{'([green]installed[/] :package:)' if build_info['installed'] else '([yellow]cloned[/] :hammer_and_wrench:)'} " f"'{build_info['version'][:7:]}' | " f"[bold]Version constraint key[/] '{vc_key}'" ) Rule() def run_checks(): """Run before CLI App load.""" from ..app import checks from ..settings.manager import SettingsManager settings = SettingsManager() # Check for any updates and inject version info into user settings. version_info = checks.check_for_updates( github_url=settings["app"]["update_check_url"], package_name="resolve_proxy_encoder", ) settings.update({"version_info": version_info}) def cli_init(): draw_banner() run_checks() # Commands @cli_app.command()
6808b8df5b16f9ff591a2b07fb0ffd878b3d2bb5
Closed in 77e0f3ff7a0b184b81987fd614c1cfaa764a6c8a
Add global option to hide banner
https://github.com/in03/Resolve-Proxy-Encoder/blob/9530708e7238af5a004eff6cd54b66014c52e791/resolve_proxy_encoder/app/cli.py#L23
6808b8df5b16f9ff591a2b07fb0ffd878b3d2bb5