From 8588f8b0ababd80f22a3f00e83ae3f925e1571e0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 10 Dec 2022 21:56:01 -0600 Subject: [PATCH] Feature: Add fll_program_print_error_parameter_cannot_use_with_without(). --- level_2/fll_program/c/program/print.c | 21 ++++++++++++++++++++ level_2/fll_program/c/program/print.h | 37 +++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index e0d74a2..03c1a79 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -98,6 +98,27 @@ extern "C" { } #endif // _di_fll_program_print_error_parameter_cannot_use_with_ +#ifndef _di_fll_program_print_error_parameter_cannot_use_with_without_ + f_status_t fll_program_print_error_parameter_cannot_use_with_without(const fl_print_t print, const f_string_static_t symbol_first, const f_string_static_t symbol_second, const f_string_static_t symbol_third, const f_string_static_t first, const f_string_static_t second, const f_string_static_t third) { + + if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QCannot specify the '%]", print.to, print.set->error, print.prefix, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol_first, first, print.set->notable); + fl_print_format("%[' parameter with the '%]", print.to, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol_second, second, print.set->notable); + fl_print_format("%[' parameter without the '%]", print.to, print.set->error, print.set->error); + fl_print_format("%[%Q%Q%]", print.to, print.set->notable, symbol_third, third, print.set->notable); + fl_print_format("%[' parameter.%]%r", print.to, print.set->error, print.set->error, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fll_program_print_error_parameter_cannot_use_with_without_ + #ifndef _di_fll_program_print_error_parameter_cannot_use_with_pipe_ f_status_t fll_program_print_error_parameter_cannot_use_with_pipe(const fl_print_t print, const f_string_static_t symbol, const f_string_static_t parameter) { diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index 5c65fc4..5f4a1e9 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -165,6 +165,43 @@ extern "C" { #endif // _di_fll_program_print_error_parameter_cannot_use_with_ /** + * Print message about two parameters not being allowed to be used together when a third is not used. + * + * This is only printed when verbosity is not set to quiet. + * + * This uses the following: + * - print.set->error: For the error context. + * - print.set->strong: For the highlighting context + * - print.prefix: For the prefixing a string to the message (such as "ERROR:"). + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol_first + * The symbol string prepended to the first parameter. + * This is usually f_console_symbol_long_normal_s. + * @param symbol_second + * The symbol string prepended to the second parameter. + * This is usually f_console_symbol_long_normal_s. + * @param symbol_third + * The symbol string prepended to the second parameter. + * This is usually f_console_symbol_long_normal_s. + * @param first + * The first parameter name (the parameter that cannot be used with the second parameter). + * @param second + * The second parameter name. + * @param third + * The third parameter name (the without parameter). + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fll_program_print_error_parameter_cannot_use_with_without_ + extern f_status_t fll_program_print_error_parameter_cannot_use_with_without(const fl_print_t print, const f_string_static_t symbol_first, const f_string_static_t symbol_second, const f_string_static_t symbol_third, const f_string_static_t first, const f_string_static_t second, const f_string_static_t third); +#endif // _di_fll_program_print_error_parameter_cannot_use_with_without_ + +/** * Print message about one parameter not being allowed to be used when processing a pipe. * * This is only printed when verbosity is not set to quiet. -- 1.8.3.1