-def fg(name: Optional[str] = "",
- red: Optional[int] = None,
- green: Optional[int] = None,
- blue: Optional[int] = None,
- *,
- force_16color: bool = False,
- force_216color: bool = False) -> str:
- import string_utils
-
+def fg(
+ name: Optional[str] = "",
+ red: Optional[int] = None,
+ green: Optional[int] = None,
+ blue: Optional[int] = None,
+ *,
+ force_16color: bool = False,
+ force_216color: bool = False,
+) -> str:
+ """Return the ANSI escape sequence to change the foreground color
+ being printed. Target colors may be indicated by name or R/G/B.
+ Result will use the 16 or 216 color scheme if force_16color or
+ force_216color are passed (respectively). Otherwise the code will
+ do what it thinks best.
+
+ Args:
+ name: the name of the color to set
+ red: the color to set's red component value
+ green: the color to set's green component value
+ blue: the color to set's blue component value
+ force_16color: force fg to use 16 color mode
+ force_216color: force fg to use 216 color mode
+
+ Returns:
+ String containing the ANSI escape sequence to set desired foreground
+
+ >>> import string_utils as su
+ >>> su.to_base64(fg('blue'))
+ b'G1szODs1OzIxbQ==\\n'
+ """