From 0fa719217ce449258938d1965b2cd1bf94171e16 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 9 May 2020 16:47:40 -0500 Subject: [PATCH] Progress: pass coloor modes and verbosity to build pre-process and build post-process scripts --- level_3/byte_dump/c/byte_dump.c | 3 + level_3/fake/c/fake.c | 39 +++++- level_3/fake/c/fake.h | 10 +- level_3/fake/c/private-build.c | 92 +++++++++++---- level_3/fake/c/private-fake.c | 203 ++++++++++++++++++++------------ level_3/fake/c/private-fake.h | 16 ++- level_3/fake/data/build/process_post.sh | 27 +++-- level_3/fake/data/build/process_pre.sh | 27 +++-- 8 files changed, 287 insertions(+), 130 deletions(-) diff --git a/level_3/byte_dump/c/byte_dump.c b/level_3/byte_dump/c/byte_dump.c index c008f3d..7baeb03 100644 --- a/level_3/byte_dump/c/byte_dump.c +++ b/level_3/byte_dump/c/byte_dump.c @@ -79,6 +79,7 @@ extern "C" { // Identify priority of color parameters. { f_console_parameter_id ids[3] = { byte_dump_parameter_no_color, byte_dump_parameter_light, byte_dump_parameter_dark }; + choices.id = ids; choices.used = 3; @@ -96,6 +97,7 @@ extern "C" { { f_console_parameter_id ids[5] = { byte_dump_parameter_hexidecimal, byte_dump_parameter_duodecimal, byte_dump_parameter_octal, byte_dump_parameter_binary, byte_dump_parameter_decimal }; f_console_parameter_id choice = byte_dump_parameter_hexidecimal; + choices.id = ids; choices.used = 5; @@ -127,6 +129,7 @@ extern "C" { { f_console_parameter_id ids[3] = { byte_dump_parameter_normal, byte_dump_parameter_simple, byte_dump_parameter_classic }; f_console_parameter_id choice = byte_dump_parameter_normal; + choices.id = ids; choices.used = 3; diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index d5fd1af..b7adac5 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -87,25 +87,56 @@ extern "C" { { f_console_parameters parameters = { data->parameters, fake_total_parameters }; - f_console_parameter_ids choices = f_console_parameter_ids_initialize; - // Identify priority of color parameters. + // Load all parameters and identify priority of color parameters. { f_console_parameter_id ids[3] = { fake_parameter_no_color, fake_parameter_light, fake_parameter_dark }; + f_console_parameter_ids choices = f_console_parameter_ids_initialize; + choices.id = ids; choices.used = 3; status = fll_program_parameter_process(arguments, parameters, choices, f_true, &data->remaining, &data->context); if (f_status_is_error(status)) { + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fll_program_parameter_process", f_true); + fake_delete_data(data); + return status; + } + } + + // Identify priority of verbosity related parameters. + { + f_console_parameter_id ids[3] = { fake_parameter_quiet, fake_parameter_verbose, fake_parameter_debug }; + f_console_parameter_ids choices = f_console_parameter_ids_initialize; + f_console_parameter_id choice = 0; + + choices.id = ids; + choices.used = 3; + + status = f_console_parameter_prioritize_right(parameters, choices, &choice); + + if (f_status_is_error(status)) { + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_console_parameter_prioritize_right", f_true); fake_delete_data(data); - return f_status_set_error(status); + return status; } - status = f_none; + if (choice == fake_parameter_quiet) { + data->verbosity = fake_verbosity_quiet; + } + else if (choice == fake_parameter_verbose) { + data->verbosity = fake_verbosity_verbose; + } + else if (choice == fake_parameter_debug) { + data->verbosity = fake_verbosity_debug; + } } + status = f_none; + // Determine order of operations. + // @todo: this should probably implemented as a standard function, such as: f_console_parameter_prioritize_set_right(). { uint8_t order_total = 0; uint8_t operations_id[fake_operations_total] = fake_operations_initialize; diff --git a/level_3/fake/c/fake.h b/level_3/fake/c/fake.h index 0732e7d..c5d109d 100644 --- a/level_3/fake/c/fake.h +++ b/level_3/fake/c/fake.h @@ -244,6 +244,13 @@ extern "C" { #define fake_operations_total 4 #define fake_operations_initialize { 0, 0, 0, 0 } + enum { + fake_verbosity_quiet = 1, + fake_verbosity_normal, + fake_verbosity_verbose, + fake_verbosity_debug, + }; + #define fake_short_defines "d" #define fake_short_mode "m" #define fake_short_process "p" @@ -418,13 +425,13 @@ extern "C" { bool process_pipe; uint8_t operation; + uint8_t verbosity; f_string_dynamic defines; f_string_dynamics mode; f_string_dynamic process; f_string_dynamic settings; - f_string_dynamic path_build; f_string_dynamic path_work; @@ -445,6 +452,7 @@ extern "C" { f_string_lengths_initialize, \ f_false, \ 0, \ + fake_verbosity_normal, \ f_string_dynamic_initialize, \ f_string_dynamics_initialize, \ f_string_dynamic_initialize, \ diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index cc8f167..bc12174 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -20,7 +20,7 @@ extern "C" { } if (f_status_is_error(status)) { - fake_print_error(data.context, f_status_set_fine(status), "fl_string_dynamic_append", f_true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fl_string_dynamic_append", f_true); f_macro_string_dynamic_delete_simple(path); return status; @@ -48,7 +48,7 @@ extern "C" { } if (f_status_is_error(status)) { - fake_print_error_file(data.context, f_status_set_fine(status), name_function, path.string, "file", f_true); + fake_print_error_file(data.context, data.verbosity, f_status_set_fine(status), name_function, path.string, "file", f_true); f_macro_string_dynamic_delete_simple(buffer); f_macro_string_dynamic_delete_simple(path); @@ -72,21 +72,25 @@ extern "C" { f_macro_string_dynamic_delete_simple(buffer); if (status == f_status_set_error(f_incomplete_utf_on_stop)) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); - fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); + if (data.verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); + fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); + } } else if (status == f_status_set_error(f_incomplete_utf_on_stop)) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); - fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); + if (data.verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%d", range.start); + fl_color_print(f_standard_error, data.context.error, data.context.reset, " of settings file '"); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "')."); + } } else { - fake_print_error(data.context, f_status_set_fine(status), "fll_fss_extended_read", true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_fss_extended_read", true); } f_macro_fss_objects_delete_simple(objects); @@ -237,7 +241,7 @@ extern "C" { } // for if (f_status_is_error(status)) { - fake_print_error(data.context, f_status_set_fine(status), "f_macro_string_dynamic_new", f_true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "f_macro_string_dynamic_new", f_true); f_macro_fss_objects_delete_simple(objects); f_macro_fss_contents_delete_simple(contents); @@ -249,12 +253,14 @@ extern "C" { if (f_status_is_error(status)) { if (status == f_status_set_error(f_string_too_large)) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: a setting in the build settings file '"); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' is too long."); + if (data.verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: a setting in the build settings file '"); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path); + fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "' is too long."); + } } else { - fake_print_error(data.context, f_status_set_fine(status), "fl_string_dynamic_partial_mash", f_true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fl_string_dynamic_partial_mash", f_true); } } } @@ -413,8 +419,42 @@ extern "C" { status = fll_execute_arguments_add(fake_other_operation_build, fake_other_operation_build_length, &arguments); + // ensure console color mode is passed to the scripts so that they can also react to color mode. + if (!f_status_is_error(status) && data.context.mode != f_color_mode_none) { + char argument[3] = { f_console_symbol_disable, 0, 0 }; + + if (data.context.mode == f_color_mode_dark) { + argument[1] = f_console_standard_short_dark[0]; + } + else if (data.context.mode == f_color_mode_light) { + argument[1] = f_console_standard_short_light[0]; + } + else if (data.context.mode == f_color_mode_no_color) { + argument[1] = f_console_standard_short_no_color[0]; + } + + status = fll_execute_arguments_add(argument, 2, &arguments); + } + + // ensure verbosity level is passed to the scripts so that they can also react to requested verbosity. + if (!f_status_is_error(status) && data.verbosity != fake_verbosity_normal) { + char argument[3] = { f_console_symbol_disable, 0, 0 }; + + if (data.verbosity == fake_verbosity_quiet) { + argument[1] = f_console_standard_short_quiet[0]; + } + else if (data.verbosity == fake_verbosity_verbose) { + argument[1] = f_console_standard_short_verbose[0]; + } + else if (data.verbosity == fake_verbosity_debug) { + argument[1] = f_console_standard_short_debug[0]; + } + + status = fll_execute_arguments_add(argument, 2, &arguments); + } + if (f_status_is_error(status)) { - fake_print_error(data.context, f_status_set_fine(status), "fll_execute_arguments_add", f_true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_execute_arguments_add", f_true); f_macro_string_dynamics_delete_simple(arguments); return status; @@ -423,7 +463,7 @@ extern "C" { status = fll_execute_arguments_add_parameter_set(parameter_prefixs, parameter_prefixs_length, parameter_names, parameter_names_length, parameter_values, parameter_values_length, parameters_total, &arguments); if (f_status_is_error(status)) { - fake_print_error(data.context, f_status_set_fine(status), "fll_execute_arguments_add_parameter_set", f_true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fll_execute_arguments_add_parameter_set", f_true); f_macro_string_dynamics_delete_simple(arguments); return status; @@ -440,7 +480,7 @@ extern "C" { } if (f_status_is_error(status)) { - fake_print_error(data.context, f_status_set_fine(status), "fl_string_dynamic_append", f_true); + fake_print_error(data.context, data.verbosity, f_status_set_fine(status), "fl_string_dynamic_append", f_true); f_macro_string_dynamic_delete_simple(path); return status; @@ -452,12 +492,14 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) == f_failure) { - fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to execute script: "); - fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); - fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "."); + if (data.verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data.context.error, data.context.reset, "ERROR: Failed to execute script: "); + fl_color_print(f_standard_error, data.context.notable, data.context.reset, "%s", path.string); + fl_color_print_line(f_standard_error, data.context.error, data.context.reset, "."); + } } else { - fake_print_error(data.context, f_status_set_fine(status), "fll_execute_path", f_true); + fake_print_error(data.context, data.verbosity != fake_verbosity_quiet, f_status_set_fine(status), "fll_execute_path", f_true); } } diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 5da80bc..06aa54b 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -6,23 +6,29 @@ extern "C" { #endif #ifndef _di_fake_print_error_ - f_return_status fake_print_error(const fl_color_context context, const f_status status, const f_string function, const bool fallback) { + f_return_status fake_print_error(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const bool fallback) { if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter in function "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print_line(f_standard_error, context.error, context.reset, "()."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter in function "); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); + fl_color_print_line(f_standard_error, context.error, context.reset, "()."); + } + return f_none; } if (status == f_error_allocation || status == f_error_reallocation) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to allocate memory in function "); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print_line(f_standard_error, context.error, context.reset, "()."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Unable to allocate memory in function "); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); + fl_color_print_line(f_standard_error, context.error, context.reset, "()."); + } + return f_none; } - if (fallback) { + if (fallback && verbosity != fake_verbosity_quiet) { fl_color_print(f_standard_error, context.error, context.reset, "UNKNOWN ERROR: ("); fl_color_print(f_standard_error, context.notable, context.reset, "%d", status); fl_color_print(f_standard_error, context.error, context.reset, ") in function "); @@ -35,74 +41,101 @@ extern "C" { #endif // _di_fake_print_error_ #ifndef _di_fake_print_error_file_ - f_return_status fake_print_error_file(const fl_color_context context, const f_status status, const f_string function, const f_string file_name, const f_string file_or_directory, const bool fallback) { + f_return_status fake_print_error_file(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string file_name, const f_string file_or_directory, const bool fallback) { if (status == f_file_not_found) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to find file '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to find file '"); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_directory_not_found) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to find directory '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: failed to find directory '"); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_invalid_parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ", function, file_name); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); - fl_color_print(f_standard_error, context.error, context.reset, "() for the %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "INTERNAL ERROR: Invalid parameter when calling ", function, file_name); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", function); + fl_color_print(f_standard_error, context.error, context.reset, "() for the %s '", file_or_directory); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_invalid_name) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid %s name '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid %s name '", file_or_directory); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_out_of_memory) { - fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to access %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_number_overflow) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Overflow while trying to access %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Overflow while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_invalid_directory) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid directory while trying to access %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Invalid directory while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_access_denied) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Access denied while trying to access %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Access denied while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } if (status == f_loop) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Loop while trying to access %s '", file_or_directory); - fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); - fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: Loop while trying to access %s '", file_or_directory); + fl_color_print(f_standard_error, context.notable, context.reset, "%s", file_name); + fl_color_print_line(f_standard_error, context.error, context.reset, "'."); + } + return f_none; } - if (fake_print_error(context, status, function, f_false) == f_unknown && fallback) { + if (fake_print_error(context, verbosity, status, function, f_false) == f_unknown && fallback && verbosity != fake_verbosity_quiet) { fl_color_print(f_standard_error, context.error, context.reset, "UNKNOWN ERROR: ("); fl_color_print(f_standard_error, context.notable, context.reset, "%d", status); fl_color_print(f_standard_error, context.error, context.reset, ") occurred for %s '", file_or_directory); @@ -115,18 +148,22 @@ extern "C" { #endif // _di_fake_print_error_file_ #ifndef _di_fake_print_error_parameter_missing_value_ - void fake_print_error_parameter_missing_value(const fl_color_context context, const f_string parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_standard_error, context.error, context.reset, "' was specified, but no value was given."); + void fake_print_error_parameter_missing_value(const fl_color_context context, const uint8_t verbosity, const f_string parameter) { + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: The parameter '"); + fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_line(f_standard_error, context.error, context.reset, "' was specified, but no value was given."); + } } #endif // _di_fake_print_error_parameter_missing_value_ #ifndef _di_fake_print_error_parameter_too_many_ - void fake_print_error_parameter_too_many(const fl_color_context context, const f_string parameter) { - fl_color_print(f_standard_error, context.error, context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print_line(f_standard_error, context.error, context.reset, "' specified too many times."); + void fake_print_error_parameter_too_many(const fl_color_context context, const uint8_t verbosity, const f_string parameter) { + if (verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, context.error, context.reset, "ERROR: the parameter '"); + fl_color_print(f_standard_error, context.notable, context.reset, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print_line(f_standard_error, context.error, context.reset, "' specified too many times."); + } } #endif // _di_fake_print_error_parameter_too_many_ @@ -155,9 +192,11 @@ extern "C" { for (uint8_t i = 0; i < total; i++) { if (data->parameters[parameter_ids[i]].total > 1) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the operation '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", parameter_names[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' specified too many times."); + if (data->verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the operation '"); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", parameter_names[i]); + fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' specified too many times."); + } return f_status_set_error(f_invalid_parameter); } @@ -194,12 +233,12 @@ extern "C" { for (uint8_t i = 0; i < total; i++) { if (data->parameters[parameter_ids[i]].result == f_console_result_found) { - fake_print_error_parameter_missing_value(data->context, parameter_names[i]); + fake_print_error_parameter_missing_value(data->context, data->verbosity, parameter_names[i]); return f_status_set_error(f_invalid_parameter); } else if (data->parameters[parameter_ids[i]].result == f_console_result_additional) { if (data->parameters[parameter_ids[i]].total > 1) { - fake_print_error_parameter_too_many(data->context, parameter_names[i]); + fake_print_error_parameter_too_many(data->context, data->verbosity, parameter_names[i]); return f_status_set_error(f_invalid_parameter); } @@ -211,12 +250,14 @@ extern "C" { if (f_status_is_error(status)) { if (status == f_status_set_error(f_string_too_large)) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is too long."); + if (data->verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); + fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is too long."); + } } else { - fake_print_error(data->context, f_status_set_fine(status), "fl_string_append", f_true); + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_string_append", f_true); } return status; @@ -227,16 +268,18 @@ extern "C" { } if (length == 0 || status == f_no_data) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' must not be empty and must not contain only whitespace."); + if (data->verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the parameter '"); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); + fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' must not be empty and must not contain only whitespace."); + } } } else if (parameter_default_lengths[i] > 0) { f_macro_string_dynamic_resize(status, (*parameter_values[i]), parameter_default_lengths[i]); if (f_status_is_error(status)) { - fake_print_error(data->context, f_status_set_fine(status), "f_macro_string_dynamic_resize", f_true); + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_macro_string_dynamic_resize", f_true); return status; } @@ -247,7 +290,7 @@ extern "C" { } if (data->parameters[fake_parameter_defines].result == f_console_result_found) { - fake_print_error_parameter_missing_value(data->context, fake_long_defines); + fake_print_error_parameter_missing_value(data->context, data->verbosity, fake_long_defines); return f_status_set_error(f_invalid_parameter); } @@ -328,19 +371,19 @@ extern "C" { for (uint8_t i = 0; i < total; i++) { if (data->parameters[parameter_ids[i]].result == f_console_result_found) { - fake_print_error_parameter_missing_value(data->context, parameter_names[i]); + fake_print_error_parameter_missing_value(data->context, data->verbosity, parameter_names[i]); return f_status_set_error(f_invalid_parameter); } else if (data->parameters[parameter_ids[i]].result == f_console_result_additional) { if (data->parameters[parameter_ids[i]].additional.used > 1) { - fake_print_error_parameter_too_many(data->context, parameter_names[i]); + fake_print_error_parameter_too_many(data->context, data->verbosity, parameter_names[i]); return f_status_set_error(f_invalid_parameter); } status = fl_console_parameter_to_string_dynamic_directory(arguments.argv[data->parameters[parameter_ids[i]].additional.array[0]], parameter_values[i]); if (f_status_is_error(status)) { - if (fake_print_error(data->context, f_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", f_false) == f_unknown) { + if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fl_console_parameter_to_string_dynamic_directory", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to process parameter '"); fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); @@ -353,7 +396,7 @@ extern "C" { f_macro_string_dynamic_new(status, (*parameter_values[i]), parameter_default_lengths[i]); if (f_status_is_error(status)) { - if (fake_print_error(data->context, f_status_set_fine(status), "f_macro_string_dynamic_new", f_false) == f_unknown) { + if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_macro_string_dynamic_new", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to load default for the parameter '"); fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, parameter_names[i]); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); @@ -377,7 +420,7 @@ extern "C" { if (f_status_is_error(status)) { if (f_status_set_fine(status) != f_directory_not_found || parameters_required[i]) { - fake_print_error_file(data->context, f_status_set_fine(status), "f_file_stat", parameter_values[i]->string, "directory", f_true); + fake_print_error_file(data->context, data->verbosity, f_status_set_fine(status), "f_file_stat", parameter_values[i]->string, "directory", f_true); return status; } } @@ -397,12 +440,14 @@ extern "C" { if (f_status_is_error(status)) { if (status == f_status_set_error(f_string_too_large)) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the (combined) parameter '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_defines); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is too long."); + if (data->verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the (combined) parameter '"); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_defines); + fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' is too long."); + } } else { - fake_print_error(data->context, f_status_set_fine(status), "fll_program_parameter_additional_rip_mash", f_true); + fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fll_program_parameter_additional_rip_mash", f_true); } return status; @@ -410,14 +455,14 @@ extern "C" { } if (data->parameters[fake_parameter_mode].result == f_console_result_found) { - fake_print_error_parameter_missing_value(data->context, fake_long_mode); + fake_print_error_parameter_missing_value(data->context, data->verbosity, fake_long_mode); return f_status_set_error(f_invalid_parameter); } else if (data->parameters[fake_parameter_mode].result == f_console_result_additional) { status = fll_program_parameter_additional_rip(arguments.argv, data->parameters[fake_parameter_mode].additional, &data->mode); if (f_status_is_error(status)) { - if (fake_print_error(data->context, f_status_set_fine(status), "fll_program_parameter_additional_rip", f_false) == f_unknown) { + if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "fll_program_parameter_additional_rip", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to process the parameter '"); fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); @@ -437,7 +482,7 @@ extern "C" { status = f_utf_is_word_dash_plus(data->mode.array[i].string + j, width_max); if (f_status_is_error(status)) { - if (fake_print_error(data->context, f_status_set_fine(status), "f_utf_is_word_dash_plus", f_false) == f_unknown) { + if (fake_print_error(data->context, data->verbosity, f_status_set_fine(status), "f_utf_is_word_dash_plus", f_false) == f_unknown && data->verbosity != fake_verbosity_quiet) { fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: failed to process the parameter '"); fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "'."); @@ -447,11 +492,13 @@ extern "C" { } if (status == f_false) { - fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); - fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameters value '"); - fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", data->mode.array[i].string); - fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' contains non-word, non-dash, and non-plus characters."); + if (data->verbosity != fake_verbosity_quiet) { + fl_color_print(f_standard_error, data->context.error, data->context.reset, "ERROR: the '"); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_mode); + fl_color_print(f_standard_error, data->context.error, data->context.reset, "' parameters value '"); + fl_color_print(f_standard_error, data->context.notable, data->context.reset, "%s", data->mode.array[i].string); + fl_color_print_line(f_standard_error, data->context.error, data->context.reset, "' contains non-word, non-dash, and non-plus characters."); + } return f_status_set_error(f_invalid_parameter); } diff --git a/level_3/fake/c/private-fake.h b/level_3/fake/c/private-fake.h index ad7543d..97cf9b6 100644 --- a/level_3/fake/c/private-fake.h +++ b/level_3/fake/c/private-fake.h @@ -17,6 +17,8 @@ extern "C" { * * @param context * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. * @param status * The status code representing an error. * @param function @@ -29,7 +31,7 @@ extern "C" { * f_unknown is returned if the status code has no print message. */ #ifndef _di_fake_print_error_ - extern f_return_status fake_print_error(const fl_color_context context, const f_status status, const f_string function, const bool fallback) f_gcc_attribute_visibility_internal; + extern f_return_status fake_print_error(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const bool fallback) f_gcc_attribute_visibility_internal; #endif // _di_fake_print_error_ /** @@ -37,6 +39,8 @@ extern "C" { * * @param context * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. * @param status * The error status code to report on. * @param function @@ -53,7 +57,7 @@ extern "C" { * f_unknown is returned if the status code has no print message. */ #ifndef _di_fake_print_error_file_ - extern f_return_status fake_print_error_file(const fl_color_context context, const f_status status, const f_string function, const f_string file_name, const f_string file_or_directory, const bool fallback) f_gcc_attribute_visibility_internal; + extern f_return_status fake_print_error_file(const fl_color_context context, const uint8_t verbosity, const f_status status, const f_string function, const f_string file_name, const f_string file_or_directory, const bool fallback) f_gcc_attribute_visibility_internal; #endif // _di_fake_print_error_file_ /** @@ -61,11 +65,13 @@ extern "C" { * * @param context * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. * @param parameter * The parameter name. */ #ifndef _di_fake_print_error_parameter_missing_value_ - extern void fake_print_error_parameter_missing_value(const fl_color_context context, const f_string parameter) f_gcc_attribute_visibility_internal; + extern void fake_print_error_parameter_missing_value(const fl_color_context context, const uint8_t verbosity, const f_string parameter) f_gcc_attribute_visibility_internal; #endif // _di_fake_print_error_parameter_missing_value_ /** @@ -73,11 +79,13 @@ extern "C" { * * @param context * The color context. + * @param verbosity + * The verbosity level, which determines if and what should be printed. * @param parameter * The parameter name. */ #ifndef _di_fake_print_error_parameter_too_many_ - extern void fake_print_error_parameter_too_many(const fl_color_context context, const f_string parameter) f_gcc_attribute_visibility_internal; + extern void fake_print_error_parameter_too_many(const fl_color_context context, const uint8_t verbosity, const f_string parameter) f_gcc_attribute_visibility_internal; #endif // _di_fake_print_error_parameter_too_many_ /** diff --git a/level_3/fake/data/build/process_post.sh b/level_3/fake/data/build/process_post.sh index 52d860b..435e9fe 100755 --- a/level_3/fake/data/build/process_post.sh +++ b/level_3/fake/data/build/process_post.sh @@ -27,6 +27,7 @@ process_post_main(){ local operation= local mode= local defines= + local verbosity= # grab all supported parameters, ignoring duplicates. if [[ $# -gt 0 ]] ; then @@ -45,6 +46,12 @@ process_post_main(){ grab_next="mode" elif [[ $p == "-d" ]] ; then grab_next="defines" + elif [[ $p == "+q" ]] ; then + verbosity=quiet + elif [[ $p == "+V" ]] ; then + verbosity=verbose + elif [[ $p == "+D" ]] ; then + verbosity=debug elif [[ $p == "+n" ]] ; then if [[ $do_color == "normal" ]] ; then do_color=none @@ -93,18 +100,20 @@ process_post_main(){ c_prefix= fi - echo - echo -e "${c_title}Done Processing Operation: $c_reset$c_notice$operation$c_reset" + if [[ $verbosity != "quiet" ]] ; then + echo + echo -e "${c_title}Done Processing Operation: $c_reset$c_notice$operation$c_reset" - if [[ $mode != "" ]] ; then - echo -e " Modes: $c_reset$c_notice$mode$c_reset" - fi + if [[ $mode != "" ]] ; then + echo -e " Modes: $c_reset$c_notice$mode$c_reset" + fi - if [[ $defines != "" ]] ; then - echo -e " Defines: $c_reset$c_notice$defines$c_reset" - fi + if [[ $defines != "" ]] ; then + echo -e " Defines: $c_reset$c_notice$defines$c_reset" + fi - echo + echo + fi # cleanup and return unset process_post_main diff --git a/level_3/fake/data/build/process_pre.sh b/level_3/fake/data/build/process_pre.sh index 7b730d3..0b6cd4a 100755 --- a/level_3/fake/data/build/process_pre.sh +++ b/level_3/fake/data/build/process_pre.sh @@ -27,6 +27,7 @@ process_pre_main(){ local operation= local mode= local defines= + local verbosity= # grab all supported parameters, ignoring duplicates. if [[ $# -gt 0 ]] ; then @@ -45,6 +46,12 @@ process_pre_main(){ grab_next="mode" elif [[ $p == "-d" ]] ; then grab_next="defines" + elif [[ $p == "+q" ]] ; then + verbosity=quiet + elif [[ $p == "+V" ]] ; then + verbosity=verbose + elif [[ $p == "+D" ]] ; then + verbosity=debug elif [[ $p == "+n" ]] ; then if [[ $do_color == "normal" ]] ; then do_color=none @@ -93,18 +100,20 @@ process_pre_main(){ c_prefix= fi - echo - echo -e "${c_title}Begin Processing Operation: $c_reset$c_notice$operation$c_reset" + if [[ $verbosity != "quiet" ]] ; then + echo + echo -e "${c_title}Begin Processing Operation: $c_reset$c_notice$operation$c_reset" - if [[ $mode != "" ]] ; then - echo -e " Modes: $c_reset$c_notice$mode$c_reset" - fi + if [[ $mode != "" ]] ; then + echo -e " Modes: $c_reset$c_notice$mode$c_reset" + fi - if [[ $defines != "" ]] ; then - echo -e " Defines: $c_reset$c_notice$defines$c_reset" - fi + if [[ $defines != "" ]] ; then + echo -e " Defines: $c_reset$c_notice$defines$c_reset" + fi - echo + echo + fi # cleanup and return unset process_pre_main -- 1.8.3.1