Package picocli

Enum CommandLine.Help.Ansi

    • Enum Constant Detail

      • AUTO

        public static final CommandLine.Help.Ansi AUTO
        Only emit ANSI escape codes if the platform supports it and system property "picocli.ansi" is not set to any value other than "true" (case insensitive).
      • ON

        public static final CommandLine.Help.Ansi ON
        Forced ON: always emit ANSI escape code regardless of the platform.
      • OFF

        public static final CommandLine.Help.Ansi OFF
        Forced OFF: never emit ANSI escape code regardless of the platform.
    • Method Detail

      • values

        public static CommandLine.Help.Ansi[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CommandLine.Help.Ansi c : CommandLine.Help.Ansi.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CommandLine.Help.Ansi valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • enabled

        public boolean enabled()
        Returns true if ANSI escape codes should be emitted, false otherwise.
        Returns:
        ON: true, OFF: false, AUTO: if system property "picocli.ansi" is defined then return its boolean value, otherwise return whether the platform supports ANSI escape codes
      • text

        public CommandLine.Help.Ansi.Text text​(String stringWithMarkup)
        Returns a new Text object for this Ansi mode, encapsulating the specified string which may contain markup like @|bg(red),white,underline some text|@.

        Calling toString() on the returned Text will either include ANSI escape codes (if this Ansi mode is ON), or suppress ANSI escape codes (if this Ansi mode is OFF).

        Equivalent to this.new Text(stringWithMarkup).

        Since:
        3.4
      • string

        public String string​(String stringWithMarkup)
        Returns a String where any markup like @|bg(red),white,underline some text|@ is converted to ANSI escape codes if this Ansi is ON, or suppressed if this Ansi is OFF.

        Equivalent to this.new Text(stringWithMarkup).toString().

        Since:
        3.4
      • valueOf

        public static CommandLine.Help.Ansi valueOf​(boolean enabled)
        Returns Ansi.ON if the specified enabled flag is true, Ansi.OFF otherwise.
        Since:
        3.4
      • apply

        public CommandLine.Help.Ansi.Text apply​(String plainText,
                                                List<CommandLine.Help.Ansi.IStyle> styles)
        Returns a new Text object where all the specified styles are applied to the full length of the specified plain text.
        Parameters:
        plainText - the string to apply all styles to. Must not contain markup!
        styles - the styles to apply to the full plain text
        Returns:
        a new Text object