snap_html.__main__
View Source
# type: ignore[attr-defined] from typing import Optional import random from enum import Enum import typer from rich.console import Console from snap_html import __version__ from snap_html.example import hello class Color(str, Enum): white = "white" red = "red" cyan = "cyan" magenta = "magenta" yellow = "yellow" green = "green" app = typer.Typer( name="snap-html", help="a robust, modern and high performance Python library for generating image from a html string/html file/url build on top of `playwright`", add_completion=False, ) console = Console() def version_callback(value: bool): """Prints the version of the package.""" if value: console.print( f"[yellow]snap-html[/] version: [bold blue]{__version__}[/]" ) raise typer.Exit() @app.command(name="") def main( name: str = typer.Option(..., help="Name of person to greet."), color: Optional[Color] = typer.Option( None, "-c", "--color", "--colour", case_sensitive=False, help="Color for name. If not specified then choice will be random.", ), version: bool = typer.Option( None, "-v", "--version", callback=version_callback, is_eager=True, help="Prints the version of the snap-html package.", ), ): """Prints a greeting for a giving name.""" if color is None: # If no color specified use random value from `Color` class color = random.choice(list(Color.__members__.values())) greeting: str = hello(name) console.print(f"[bold {color}]{greeting}[/]")
class
Color(builtins.str, enum.Enum):
View Source
class Color(str, Enum): white = "white" red = "red" cyan = "cyan" magenta = "magenta" yellow = "yellow" green = "green"
An enumeration.
Color()
white = <Color.white: 'white'>
red = <Color.red: 'red'>
cyan = <Color.cyan: 'cyan'>
magenta = <Color.magenta: 'magenta'>
yellow = <Color.yellow: 'yellow'>
green = <Color.green: 'green'>
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
def
version_callback(value: bool):
View Source
def version_callback(value: bool): """Prints the version of the package.""" if value: console.print( f"[yellow]snap-html[/] version: [bold blue]{__version__}[/]" ) raise typer.Exit()
Prints the version of the package.
@app.command(name='')
def
main(
name: str = <typer.models.OptionInfo object at 0x7f804c67e070>,
color: Union[snap_html.__main__.Color, NoneType] = <typer.models.OptionInfo object at 0x7f804c67e0a0>,
version: bool = <typer.models.OptionInfo object at 0x7f804c67e0d0>
):
View Source
@app.command(name="") def main( name: str = typer.Option(..., help="Name of person to greet."), color: Optional[Color] = typer.Option( None, "-c", "--color", "--colour", case_sensitive=False, help="Color for name. If not specified then choice will be random.", ), version: bool = typer.Option( None, "-v", "--version", callback=version_callback, is_eager=True, help="Prints the version of the snap-html package.", ), ): """Prints a greeting for a giving name.""" if color is None: # If no color specified use random value from `Color` class color = random.choice(list(Color.__members__.values())) greeting: str = hello(name) console.print(f"[bold {color}]{greeting}[/]")
Prints a greeting for a giving name.