sqlmesh.cli.options
1from __future__ import annotations 2 3import os 4import typing as t 5 6import click 7 8paths = click.option( 9 "-p", 10 "--paths", 11 multiple=True, 12 default=[os.getcwd()], 13 help="Path(s) to the SQLMesh config/project.", 14) 15 16config = click.option( 17 "--config", 18 help="Name of the config object. Only applicable to configuration defined using Python script.", 19) 20 21start_time = click.option( 22 "-s", 23 "--start", 24 required=False, 25 help="The start datetime of the interval for which this command will be applied.", 26) 27 28end_time = click.option( 29 "-e", 30 "--end", 31 required=False, 32 help="The end datetime of the interval for which this command will be applied.", 33) 34 35execution_time = click.option( 36 "--execution-time", 37 help="The execution time (defaults to now).", 38) 39 40expand = click.option( 41 "--expand", 42 multiple=True, 43 help="Whether or not to expand materialized models (defaults to False). If True, all referenced models are expanded as raw queries. Multiple model names can also be specified, in which case only they will be expanded as raw queries.", 44) 45 46match_pattern = click.option( 47 "-k", 48 multiple=True, 49 help="Only run tests that match the pattern of substring.", 50) 51 52verbose = click.option( 53 "-v", 54 "--verbose", 55 count=True, 56 help="Verbose output. Use -vv for very verbose output.", 57) 58 59 60def format_options(func: t.Callable) -> t.Callable: 61 """Decorator to add common format options to CLI commands.""" 62 func = click.option( 63 "--normalize", 64 is_flag=True, 65 help="Whether or not to normalize identifiers to lowercase.", 66 default=None, 67 )(func) 68 func = click.option( 69 "--pad", 70 type=int, 71 help="Determines the pad size in a formatted string.", 72 )(func) 73 func = click.option( 74 "--indent", 75 type=int, 76 help="Determines the indentation size in a formatted string.", 77 )(func) 78 func = click.option( 79 "--normalize-functions", 80 type=str, 81 help="Whether or not to normalize all function names. Possible values are: 'upper', 'lower'", 82 )(func) 83 func = click.option( 84 "--leading-comma", 85 is_flag=True, 86 default=None, 87 help="Determines whether or not the comma is leading or trailing in select expressions. Default is trailing.", 88 )(func) 89 func = click.option( 90 "--max-text-width", 91 type=int, 92 help="The max number of characters in a segment before creating new lines in pretty mode.", 93 )(func) 94 return func
def
paths(f: ~FC) -> ~FC:
def
config(f: ~FC) -> ~FC:
def
start_time(f: ~FC) -> ~FC:
def
end_time(f: ~FC) -> ~FC:
def
execution_time(f: ~FC) -> ~FC:
def
expand(f: ~FC) -> ~FC:
def
match_pattern(f: ~FC) -> ~FC:
def
verbose(f: ~FC) -> ~FC:
def
format_options(func: Callable) -> Callable:
61def format_options(func: t.Callable) -> t.Callable: 62 """Decorator to add common format options to CLI commands.""" 63 func = click.option( 64 "--normalize", 65 is_flag=True, 66 help="Whether or not to normalize identifiers to lowercase.", 67 default=None, 68 )(func) 69 func = click.option( 70 "--pad", 71 type=int, 72 help="Determines the pad size in a formatted string.", 73 )(func) 74 func = click.option( 75 "--indent", 76 type=int, 77 help="Determines the indentation size in a formatted string.", 78 )(func) 79 func = click.option( 80 "--normalize-functions", 81 type=str, 82 help="Whether or not to normalize all function names. Possible values are: 'upper', 'lower'", 83 )(func) 84 func = click.option( 85 "--leading-comma", 86 is_flag=True, 87 default=None, 88 help="Determines whether or not the comma is leading or trailing in select expressions. Default is trailing.", 89 )(func) 90 func = click.option( 91 "--max-text-width", 92 type=int, 93 help="The max number of characters in a segment before creating new lines in pretty mode.", 94 )(func) 95 return func
Decorator to add common format options to CLI commands.