def pprint_wrap()

in samcli/commands/_utils/table_print.py [0:0]


    def pprint_wrap(func):
        # Calculate terminal width, number of columns in the table
        width, _ = shutil.get_terminal_size()
        # For UX purposes, set a minimum width for the table to be usable
        # and usable_width keeps margins in mind.
        width = max(width, min_width)

        total_args = len(format_kwargs)
        if not total_args:
            raise ValueError("Number of arguments supplied should be > 0 , format_kwargs: {}".format(format_kwargs))

        # Get width to be a usable number so that we can equally divide the space for all the columns.
        # Can be refactored, to allow for modularity in the shaping of the columns.
        width = width - (width % total_args)
        usable_width_no_margin = int(width) - 1
        usable_width = int((usable_width_no_margin - (margin if margin else min_margin)))
        if total_args > int(usable_width / 2):
            raise ValueError("Total number of columns exceed available width")
        width_per_column = int(usable_width / total_args)

        # The final column should not roll over into the next line
        final_arg_width = width_per_column - 1

        # the format string contains minimumwidth that need to be set.
        # eg: "{a:{0}}} {b:<{1}}} {c:{2}}}"
        format_args = [width_per_column for _ in range(total_args - 1)]
        format_args.extend([final_arg_width])

        # format arguments are now ready for setting minimumwidth

        @wraps(func)
        def wrap(*args, **kwargs):
            # The table is setup with the column names, format_string contains the column names.
            if table_header:
                click.secho(
                    "\n" + table_header.format(args[0].client_sleep) if display_sleep else table_header, bold=True
                )
            click.secho("-" * usable_width, fg=color)
            click.secho(format_string.format(*format_args, **format_kwargs), fg=color)
            click.secho("-" * usable_width, fg=color)
            # format_args which have the minimumwidth set per {} in the format_string is passed to the function
            # which this decorator wraps, so that the function has access to the correct format_args
            kwargs["format_args"] = format_args
            kwargs["width"] = width_per_column
            kwargs["margin"] = margin if margin else min_margin
            result = func(*args, **kwargs)
            # Complete the table
            click.secho("-" * usable_width + "\n", fg=color)
            return result

        return wrap