1313import yaml
1414from dateutil import parser
1515from rich .console import Console
16- from rich .live import Live
1716
18- from probely .cli .enums import EntityTypeEnum , OutputEnum
17+ from probely .cli .enums import OutputEnum
18+ from probely .cli .tables .base_table import BaseOutputTable
1919from probely .sdk .enums import ProbelyCLIEnum
2020
2121UNKNOWN_VALUE_REP = "UNKNOWN"
@@ -32,12 +32,12 @@ def __init__(
3232 records : Generator [dict , None , None ],
3333 output_type : Optional [OutputEnum ],
3434 console : Console ,
35- entity_type : EntityTypeEnum ,
35+ table_cls : Type [ BaseOutputTable ] ,
3636 ):
3737 self .records = records
3838 self .output_type = output_type
3939 self .console = console
40- self .entity_type = entity_type
40+ self .table_cls = table_cls
4141
4242 def render (self ) -> None :
4343 if self .output_type == OutputEnum .JSON :
@@ -62,15 +62,13 @@ def _render_yaml(self) -> None:
6262 self .console .print (yaml .dump ([record ], indent = 2 , width = sys .maxsize ))
6363
6464 def _render_table (self ) -> None :
65- from probely .cli .tables .table_factory import ( # Avoid circular import
66- TableFactory ,
67- )
68-
69- table_cls = TableFactory .get_table_class (self .entity_type )
70- table = table_cls ().create_table (show_header = True )
71- with Live (table , console = self .console ):
72- for record in self .records :
73- table_cls ().add_row (table , record )
65+ table = self .table_cls .create_table (show_header = True )
66+ self .console .print (table )
67+
68+ for record in self .records :
69+ table = self .table_cls .create_table (show_header = False )
70+ self .table_cls .add_row (table , record )
71+ self .console .print (table )
7472
7573
7674def get_printable_enum_value (enum : Type [ProbelyCLIEnum ], api_enum_value : str ) -> str :
0 commit comments