def station_options(command): """ Station options for cli, which can be used for stations_result and values endpoint :param command: :return: """ arguments = [ cloup.option("--parameter", type=StringListParamType(","), required=True), cloup.option("--resolution", type=click.STRING, required=True), cloup.option("--period", type=StringListParamType(",")), cloup.option_group("All stations_result", click.option("--all", "all_", is_flag=True)), cloup.option_group( "Station id filtering", cloup.option("--station", type=StringListParamType(",")), ), cloup.option_group( "Station name filtering", cloup.option("--name", type=click.STRING), ), cloup.option_group( "Latitude-Longitude rank/distance filtering", cloup.option("--coordinates", metavar="LATITUDE,LONGITUDE", type=click.STRING), cloup.option("--rank", type=click.INT), cloup.option("--distance", type=click.FLOAT), help="Provide --coordinates plus either --rank or --distance.", ), cloup.constraint( If("coordinates", then=RequireExactly(1), else_=accept_none), ["rank", "distance"], ), cloup.option_group( "BBOX filtering", cloup.option("--bbox", metavar="LEFT BOTTOM RIGHT TOP", type=click.STRING), ), cloup.option_group( "SQL filtering", click.option("--sql", type=click.STRING), ), cloup.constraint( RequireExactly(1), ["all_", "station", "name", "coordinates", "bbox", "sql"], ), ] return functools.reduce(lambda x, opt: opt(x), reversed(arguments), command)
from __future__ import annotations import click from cloup import option, option_group output_options = option_group( "Output options", option( "-o", "--output_file", type=str, default=None, help="Specify the filename(s) of the rendered scene(s).", ), option( "-0", "--zero_pad", type=click.IntRange(0, 9), default=None, help="Zero padding for PNG file names.", ), option( "--write_to_movie", is_flag=True, default=None, help="Write the video rendered with opengl to a file.", ), option( "--media_dir", type=click.Path(), default=None,
def validate_resolution(ctx, param, value): if value: try: start, end = map(int, re.split(";|,|-", value)) return (start, end) except Exception: logger.error("Resolution option is invalid.") exit() render_options = option_group( "Render Options", option( "-n", "--from_animation_number", callback=validate_scene_range, help="Start rendering from n_0 until n_1. If n_1 is left unspecified, " "renders all scenes after n_0.", ), option( "-a", "--write_all", is_flag=True, help="Render all scenes in the input file.", ), option( "--format", type=click.Choice(["png", "gif", "mp4"], case_sensitive=False), ), option("-s", "--save_last_frame", is_flag=True), option(
def validate_gui_location(ctx, param, value): if value: try: x_offset, y_offset = map(int, re.split(r"[;,\-]", value)) return (x_offset, y_offset) except Exception: logger.error("GUI location option is invalid.") exit() global_options: OptionGroupDecorator = option_group( "Global options", option( "-c", "--config_file", help="Specify the configuration file to use for render settings.", default=None, ), option( "--custom_folders", is_flag=True, default=None, help="Use the folders defined in the [custom_folders] section of the " "config file to define the output folder structure.", ), option( "--disable_caching", is_flag=True, default=None, help="Disable the use of the cache (still generates cache files).", ),
def validate_gui_location(ctx, param, value): if value: try: x_offset, y_offset = map(int, re.split(";|,|-", value)) return (x_offset, y_offset) except Exception: logger.error("GUI location option is invalid.") exit() global_options = option_group( "Global options", option( "-c", "--config_file", help="Specify the configuration file to use for render settings.", ), option( "--custom_folders", is_flag=True, help="Use the folders defined in the [custom_folders] section of the " "config file to define the output folder structure.", ), option( "--disable_caching", is_flag=True, help="Disable the use of the cache (still generates cache files).", ), option("--flush_cache", is_flag=True, help="Remove cached partial movie files."), option("--tex_template", help="Specify a custom TeX template file."),
import click from cloup import option, option_group output_options = option_group( "Output options", option( "-o", "--output_file", multiple=True, help="Specify the filename(s) of the rendered scene(s).", ), option( "--write_to_movie", is_flag=True, default=None, help="Write to a file.", ), option( "--media_dir", type=click.Path(), help="Path to store rendered videos and latex.", ), option("--log_dir", type=click.Path(), help="Path to store render logs."), option( "--log_to_file", is_flag=True, help="Log terminal output to file.", ), )
import click from cloup import option, option_group ease_of_access_options = option_group( "Ease of access options", option( "--progress_bar", default=None, show_default=False, type=click.Choice( ["display", "leave", "none"], case_sensitive=False, ), help="Display progress bars and/or keep them displayed.", ), option( "-p", "--preview", is_flag=True, help="Preview the Scene's animation. OpenGL does a live preview in a " "popup window. Cairo opens the rendered video file in the system " "default media player.", default=None, ), option( "-f", "--show_in_file_browser", is_flag=True, help="Show the output file in the file browser.", default=None, ),
def validate_resolution(ctx, param, value): if value: try: start, end = map(int, re.split(r"[;,\-]", value)) return (start, end) except Exception: logger.error("Resolution option is invalid.") exit() render_options = option_group( "Render Options", option( "-n", "--from_animation_number", callback=validate_scene_range, help="Start rendering from n_0 until n_1. If n_1 is left unspecified, " "renders all scenes after n_0.", default=None, ), option( "-a", "--write_all", is_flag=True, help="Render all scenes in the input file.", default=None, ), option( "--format", type=click.Choice(["png", "gif", "mp4", "webm", "mov"], case_sensitive=False), default=None, ),
import click from cloup import option, option_group global_options = option_group( "Global options", option( "-c", "--config_file", help="Specify the configuration file to use for render settings.", ), option( "--custom_folders", is_flag=True, help="Use the folders defined in the [custom_folders] section of the " "config file to define the output folder structure.", ), option( "--disable_caching", is_flag=True, help="Disable the use of the cache (still generates cache files).", ), option("--flush_cache", is_flag=True, help="Remove cached partial movie files."), option("--tex_template", help="Specify a custom TeX template file."), option( "-v", "--verbosity", type=click.Choice( ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], case_sensitive=False,
from haku.utils import tmpdir from haku.utils.cli import Console CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"]) C_WIDTH = 100 @cloup.command(context_settings=CONTEXT_SETTINGS) @click.argument("url", required=False) @cloup.option_group( "Basic usage", cloup.option( "-o", "--out", type=click.Path(exists=True, file_okay=False, writable=True, resolve_path=True), default=Path.cwd(), show_default=".", ), cloup.option( "-c", "--convert", type=click.Choice(["pdf"], case_sensitive=False), ), cloup.option( "-m", "--merge", type=click.Choice(["volume", "manga"], case_sensitive=False), ), cloup.option("-y", "--yes", is_flag=True),
return @cli.command("stations_result") @provider_opt @network_opt @station_options @cloup.option_group( "Format/Target", click.option( "--format", "fmt", type=click.Choice(["json", "geojson", "csv"], case_sensitive=False), default="json", ), cloup.option("--target", type=click.STRING), ) @cloup.constraint( If("coordinates", then=RequireExactly(1), else_=accept_none), ["rank", "distance"], ) @cloup.option("--pretty", is_flag=True) @debug_opt def stations( provider: str, network: str, parameter: List[str], resolution: str, period: List[str], all_: bool, station: List[str],
import click from cloup import option, option_group streaming_options = option_group( "Streaming options", option( "--use-ipython", is_flag=True, help="Use IPython as the interactive console", ), # Make this option sensible and available # option( # "-sp", # "--streaming_protocol", # type=click.Choice( # ["rtp", "udp"], # case_sensitive=False, # ), # help="Streaming protocol to use for livestreaming configuration", # ), )