2424from rich .syntax import Syntax
2525from rich .table import Table
2626from rich .tree import Tree
27-
27+ from sqlmesh . core . constants import Verbosity
2828from sqlmesh .core .environment import EnvironmentNamingInfo
2929from sqlmesh .core .linter .rule import RuleViolation
3030from sqlmesh .core .model import Model
@@ -310,10 +310,13 @@ def show_row_diff(
310310 def print_environments (self , environments_summary : t .Dict [str , int ]) -> None :
311311 """Prints all environment names along with expiry datetime."""
312312
313- def _limit_model_names (self , tree : Tree , verbose : bool = False ) -> Tree :
313+ def _limit_model_names (self , tree : Tree , verbosity : Verbosity = Verbosity . DEFAULT ) -> Tree :
314314 """Trim long indirectly modified model lists below threshold."""
315315 modified_length = len (tree .children )
316- if not verbose and modified_length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD :
316+ if (
317+ verbosity < Verbosity .VERY_VERBOSE
318+ and modified_length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD
319+ ):
317320 tree .children = [
318321 tree .children [0 ],
319322 Tree (f".... { modified_length - 2 } more ...." ),
@@ -516,7 +519,7 @@ class TerminalConsole(Console):
516519 def __init__ (
517520 self ,
518521 console : t .Optional [RichConsole ] = None ,
519- verbose : bool = False ,
522+ verbosity : Verbosity = Verbosity . DEFAULT ,
520523 dialect : DialectType = None ,
521524 ignore_warnings : bool = False ,
522525 ** kwargs : t .Any ,
@@ -548,7 +551,7 @@ def __init__(
548551
549552 self .loading_status : t .Dict [uuid .UUID , Status ] = {}
550553
551- self .verbose = verbose
554+ self .verbosity = verbosity
552555 self .dialect = dialect
553556 self .ignore_warnings = ignore_warnings
554557
@@ -673,7 +676,7 @@ def start_creation_progress(
673676 def update_creation_progress (self , snapshot : SnapshotInfoLike ) -> None :
674677 """Update the snapshot creation progress."""
675678 if self .creation_progress is not None and self .creation_task is not None :
676- if self .verbose :
679+ if self .verbosity >= Verbosity . VERBOSE :
677680 self .creation_progress .live .console .print (
678681 f"{ snapshot .display_name (self .environment_naming_info , self .default_catalog , dialect = self .dialect )} [green]created[/green]"
679682 )
@@ -749,7 +752,7 @@ def start_promotion_progress(
749752 def update_promotion_progress (self , snapshot : SnapshotInfoLike , promoted : bool ) -> None :
750753 """Update the snapshot promotion progress."""
751754 if self .promotion_progress is not None and self .promotion_task is not None :
752- if self .verbose :
755+ if self .verbosity >= Verbosity . VERBOSE :
753756 action_str = "[green]promoted[/green]" if promoted else "[yellow]demoted[/yellow]"
754757 self .promotion_progress .live .console .print (
755758 f"{ snapshot .display_name (self .environment_naming_info , self .default_catalog , dialect = self .dialect )} { action_str } "
@@ -971,15 +974,15 @@ def _show_summary_tree_for(
971974 added_tree .add (
972975 f"[added]{ snapshot .display_name (environment_naming_info , default_catalog , dialect = self .dialect )} "
973976 )
974- tree .add (self ._limit_model_names (added_tree , self .verbose ))
977+ tree .add (self ._limit_model_names (added_tree , self .verbosity ))
975978 if removed_snapshot_ids :
976979 removed_tree = Tree ("[bold][removed]Removed:" )
977980 for s_id in sorted (removed_snapshot_ids ):
978981 snapshot_table_info = context_diff .removed_snapshots [s_id ]
979982 removed_tree .add (
980983 f"[removed]{ snapshot_table_info .display_name (environment_naming_info , default_catalog , dialect = self .dialect )} "
981984 )
982- tree .add (self ._limit_model_names (removed_tree , self .verbose ))
985+ tree .add (self ._limit_model_names (removed_tree , self .verbosity ))
983986 if modified_snapshot_ids :
984987 direct = Tree ("[bold][direct]Directly Modified:" )
985988 indirect = Tree ("[bold][indirect]Indirectly Modified:" )
@@ -1007,7 +1010,7 @@ def _show_summary_tree_for(
10071010 if direct .children :
10081011 tree .add (direct )
10091012 if indirect .children :
1010- tree .add (self ._limit_model_names (indirect , self .verbose ))
1013+ tree .add (self ._limit_model_names (indirect , self .verbosity ))
10111014 if metadata .children :
10121015 tree .add (metadata )
10131016 self ._print (tree )
@@ -1077,7 +1080,7 @@ def _prompt_categorize(
10771080 f"[indirect]{ child_snapshot .display_name (plan .environment_naming_info , default_catalog , dialect = self .dialect )} "
10781081 )
10791082 if indirect_tree :
1080- indirect_tree = self ._limit_model_names (indirect_tree , self .verbose )
1083+ indirect_tree = self ._limit_model_names (indirect_tree , self .verbosity )
10811084
10821085 self ._print (tree )
10831086 if not no_prompts :
@@ -1107,7 +1110,7 @@ def _show_categorized_snapshots(self, plan: Plan, default_catalog: t.Optional[st
11071110 f"[indirect]{ child_snapshot .display_name (plan .environment_naming_info , default_catalog , dialect = self .dialect )} ({ child_category_str } )"
11081111 )
11091112 if indirect_tree :
1110- indirect_tree = self ._limit_model_names (indirect_tree , self .verbose )
1113+ indirect_tree = self ._limit_model_names (indirect_tree , self .verbosity )
11111114 elif context_diff .metadata_updated (snapshot .name ):
11121115 tree = Tree (
11131116 f"\n [bold][metadata]Metadata Updated: { snapshot .display_name (plan .environment_naming_info , default_catalog , dialect = self .dialect )} "
@@ -1144,7 +1147,7 @@ def _show_missing_dates(self, plan: Plan, default_catalog: t.Optional[str]) -> N
11441147 )
11451148
11461149 if backfill :
1147- backfill = self ._limit_model_names (backfill , self .verbose )
1150+ backfill = self ._limit_model_names (backfill , self .verbosity )
11481151 self ._print (backfill )
11491152
11501153 def _prompt_effective_from (
@@ -1993,7 +1996,10 @@ def show_model_difference_summary(
19931996 self ._print ("\n **Added Models:**" )
19941997 added_models = sorted (added_snapshot_models )
19951998 list_length = len (added_models )
1996- if not self .verbose and list_length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD :
1999+ if (
2000+ self .verbosity < Verbosity .VERY_VERBOSE
2001+ and list_length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD
2002+ ):
19972003 self ._print (added_models [0 ])
19982004 self ._print (f"- `.... { list_length - 2 } more ....`\n " )
19992005 self ._print (added_models [- 1 ])
@@ -2017,7 +2023,10 @@ def show_model_difference_summary(
20172023 self ._print ("\n **Removed Models:**" )
20182024 removed_models = sorted (removed_model_snapshot_table_infos )
20192025 list_length = len (removed_models )
2020- if not self .verbose and list_length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD :
2026+ if (
2027+ self .verbosity < Verbosity .VERY_VERBOSE
2028+ and list_length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD
2029+ ):
20212030 self ._print (removed_models [0 ])
20222031 self ._print (f"- `.... { list_length - 2 } more ....`\n " )
20232032 self ._print (removed_models [- 1 ])
@@ -2062,7 +2071,7 @@ def show_model_difference_summary(
20622071 indirectly_modified = sorted (indirectly_modified )
20632072 modified_length = len (indirectly_modified )
20642073 if (
2065- not self .verbose
2074+ self .verbosity < Verbosity . VERY_VERBOSE
20662075 and modified_length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD
20672076 ):
20682077 self ._print (
@@ -2106,7 +2115,10 @@ def _show_missing_dates(self, plan: Plan, default_catalog: t.Optional[str]) -> N
21062115 )
21072116
21082117 length = len (snapshots )
2109- if not self .verbose and length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD :
2118+ if (
2119+ self .verbosity < Verbosity .VERY_VERBOSE
2120+ and length > self .INDIRECTLY_MODIFIED_DISPLAY_THRESHOLD
2121+ ):
21102122 self ._print (snapshots [0 ])
21112123 self ._print (f"- `.... { length - 2 } more ....`\n " )
21122124 self ._print (snapshots [- 1 ])
@@ -2135,7 +2147,7 @@ def _show_categorized_snapshots(self, plan: Plan, default_catalog: t.Optional[st
21352147 f"[indirect]{ child_snapshot .display_name (plan .environment_naming_info , default_catalog , dialect = self .dialect )} ({ child_category_str } )"
21362148 )
21372149 if indirect_tree :
2138- indirect_tree = self ._limit_model_names (indirect_tree , self .verbose )
2150+ indirect_tree = self ._limit_model_names (indirect_tree , self .verbosity )
21392151 elif context_diff .metadata_updated (snapshot .name ):
21402152 tree = Tree (
21412153 f"[bold][metadata]Metadata Updated: { snapshot .display_name (plan .environment_naming_info , default_catalog , dialect = self .dialect )} "
@@ -2364,7 +2376,7 @@ def __init__(
23642376 ) -> None :
23652377 self .console : RichConsole = console or srich .console
23662378 self .dialect = dialect
2367- self .verbose = False
2379+ self .verbosity = Verbosity . DEFAULT
23682380 self .ignore_warnings = ignore_warnings
23692381
23702382 def _write (self , msg : t .Any , * args : t .Any , ** kwargs : t .Any ) -> None :
0 commit comments