35 auto term_parse_error_callback(
const char *what, std::source_location where)
36 -> std::invalid_argument {
73 bool has_opt_nocolor =
has_option(
"--nocolor");
76 if (has_opt_color && has_opt_nocolor) {
78 "You can not pass --nocolor and --color simultaneously");
91 .COLORTERM = COLORTERM,
93 .CLICOLOR_FORCE = CLICOLOR_FORCE,
96 term_parse_error_callback);
98 if (has_opt_nocolor) {
100 }
else if (has_opt_color) {
This header file contains utility functions related to exception handling in the code.
This file handler generic cli & env options.
void println(std::string_view sv)
Prints a string to the console followed by a newline.
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
namespace for cli utilities
void process_cmdopt_generic_opts()
Process generic cli and env variables options.
bool has_option(const std::string_view &option_name)
Check if an option is present.
void register_cmdopt_generic_opts()
Register generic cli and env variables options.
void process_env_vars()
Detect if the current process should use colored output or not.
void register_env_var_doc(std::string env_var, std::string desc)
Register the documentation of an environment variable.
std::optional< std::string_view > getenv_str_view(const char *env_var)
Get the content of the environment variable if it exist.
void register_opt(std::string name, std::optional< std::string > args, std::string description)
Register a command line option.
void print_help()
Print the help message.
Environment variable parsing for terminal color and size configuration (TERM, COLORTERM,...
void parse_terminal_support(TermEnvVars vars, const term_parse_callback_t &error_callback)
Parses terminal environment variables to determine color support and set terminal size.
provide information about the source location
bool colors_enabled()
Are colors enabled.
void disable_colors()
Disable all colors.
void enable_colors()
Enable colors in logs.
This file contains tty info getters.
int get_tty_columns()
Get the number of columns of the current terminal.
int get_tty_lines()
Get the number of lines of the current terminal.
bool is_a_tty()
Test if current terminal is a tty.