diff --git a/core/dbt/config/profile.py b/core/dbt/config/profile.py index 835718ea25a..d48c16b295f 100644 --- a/core/dbt/config/profile.py +++ b/core/dbt/config/profile.py @@ -59,9 +59,10 @@ def read_profile(profiles_dir): class UserConfig(object): - def __init__(self, send_anonymous_usage_stats, use_colors): + def __init__(self, send_anonymous_usage_stats, use_colors, printer_width): self.send_anonymous_usage_stats = send_anonymous_usage_stats self.use_colors = use_colors + self.printer_width = printer_width @classmethod def from_dict(cls, cfg=None): @@ -75,7 +76,10 @@ def from_dict(cls, cfg=None): 'use_colors', DEFAULT_USE_COLORS ) - return cls(send_anonymous_usage_stats, use_colors) + printer_width = cfg.get( + 'printer_width' + ) + return cls(send_anonymous_usage_stats, use_colors, printer_width) def to_dict(self): return { diff --git a/core/dbt/main.py b/core/dbt/main.py index 18f1dacd9b6..34907f196e1 100644 --- a/core/dbt/main.py +++ b/core/dbt/main.py @@ -134,6 +134,9 @@ def initialize_config_values(parsed): if cfg.use_colors: dbt.ui.printer.use_colors() + if cfg.printer_width: + dbt.ui.printer.printer_width(cfg.printer_width) + def handle_and_check(args): parsed = parse_args(args) diff --git a/core/dbt/ui/printer.py b/core/dbt/ui/printer.py index 8bbdd294ae8..a862c8e4c49 100644 --- a/core/dbt/ui/printer.py +++ b/core/dbt/ui/printer.py @@ -13,12 +13,19 @@ COLOR_FG_YELLOW = dbt.ui.colors.COLORS['yellow'] COLOR_RESET_ALL = dbt.ui.colors.COLORS['reset_all'] +PRINTER_WIDTH = 80 + def use_colors(): global USE_COLORS USE_COLORS = True +def printer_width(printer_width): + global PRINTER_WIDTH + PRINTER_WIDTH = printer_width + + def get_timestamp(): return time.strftime("%H:%M:%S") @@ -60,9 +67,10 @@ def print_fancy_output_line(msg, status, index, total, execution_time=None, progress=progress, message=msg) - justified = prefix.ljust(80, ".") - if truncate and len(justified) > 77: - justified = justified[:77] + '...' + truncate_width = PRINTER_WIDTH - 3 + justified = prefix.ljust(PRINTER_WIDTH, ".") + if truncate and len(justified) > truncate_width: + justified = justified[:truncate_width] + '...' if execution_time is None: status_time = "" diff --git a/test/unit/test_config.py b/test/unit/test_config.py index ce3971a89c4..c2c70dba04b 100644 --- a/test/unit/test_config.py +++ b/test/unit/test_config.py @@ -239,12 +239,14 @@ def test_config_override(self): def test_partial_config_override(self): self.default_profile_data['config'] = { 'send_anonymous_usage_stats': False, + 'printer_width': 60 } profile = self.from_raw_profiles() self.assertEqual(profile.profile_name, 'default') self.assertEqual(profile.target_name, 'postgres') self.assertFalse(profile.config.send_anonymous_usage_stats) self.assertTrue(profile.config.use_colors) + self.assertEqual(profile.config.printer_width, 60) def test_missing_type(self): del self.default_profile_data['default']['outputs']['postgres']['type']