java.lang.Object
polimi.ingsw.am21.codex.view.TUI.utils.CliUtils

public class CliUtils extends Object
  • Constructor Details

    • CliUtils

      public CliUtils()
  • Method Details

    • joinMinLines

      public static String joinMinLines(String s1, String s2)
      Parameters:
      s1 - the first string to be returned
      s2 - the second string to be returned
      Returns:
      the concatenated lines of the two given strings: it has a number of lines equal to the minimum between the number of lines of s1 and s2. The rest are discarded.
    • colorize

      public static <T extends Colorable> String colorize(T colorable, ColorStyle style, int length)
      Colorizes a string with the given color and style, automatically resetting the formatting afterward
      Parameters:
      colorable - The colorable to colorize
      style - The style to use
      length - The length to truncate the string to
    • colorize

      public static <T extends Colorable> String colorize(T colorable, ColorStyle style)
      Colorizes a string with the given color and style, automatically resetting the formatting afterward
      Parameters:
      colorable - The colorable to colorize
      style - The style to use
    • colorize

      public static String colorize(String string, Color color, ColorStyle style)
      Colorizes a string with the given color and style, automatically resetting the formatting afterward
      Parameters:
      string - The string to colorize
      color - The color to use
      style - The style to use
    • colorizeAndCenter

      public static <T extends Colorable> String colorizeAndCenter(List<T> colorables, int length, char padChar, ColorStyle style)
      Colorizes a string with the given color and style, automatically resetting the formatting afterward
      Parameters:
      colorables - The list of colorable elements to colorize
      length - The length to truncate the string to
      padChar - The character to pad the string with
      style - The style to use
    • getColorableLength

      public static int getColorableLength(Colorable colorable, int colorableSize, ColorStyle style)
      Gets the length of a colorable element when colorized with the given style
      Parameters:
      colorable - The colorable element
      colorableSize - The size of the colorable element
      style - The style to use
    • getTable

      @SafeVarargs public static String getTable(String[] headers, ArrayList<String>... columns)
      Gets a table with the given headers and columns
      Parameters:
      headers - The headers of the table
      columns - The columns of the table