From 0df2cee5300b5aeb32a124697f9659bb4ed66909 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 18 Sep 2020 22:20:27 -0500 Subject: [PATCH] Cleanup: add -c/--content for consistency to iki_read. The -c/--content is the default behavior. This adds a literal parameter to reflect this. No new functionality is added other than validation on the -c/--content parameter. --- level_3/iki_read/c/iki_read.c | 32 ++++++++++++++++++++++++++++++-- level_3/iki_read/c/iki_read.h | 6 +++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 4d16762..3229389 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -26,8 +26,9 @@ extern "C" { printf("%c", f_string_eol[0]); - fll_program_print_help_option(context, iki_read_short_literal, iki_read_long_literal, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print the entire variable instead of the content."); - fll_program_print_help_option(context, iki_read_short_object, iki_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the variable name instead of the variable content."); + fll_program_print_help_option(context, iki_read_short_content, iki_read_long_content, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print the variable content (default)."); + fll_program_print_help_option(context, iki_read_short_literal, iki_read_long_literal, f_console_symbol_short_enable, f_console_symbol_long_enable, "Print the entire variable (aka: object, content, and syntax)."); + fll_program_print_help_option(context, iki_read_short_object, iki_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the variable name (aka: object)."); fll_program_print_help_option(context, iki_read_short_total, iki_read_long_total, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the total number of variables."); printf("%c", f_string_eol[0]); @@ -260,6 +261,19 @@ extern "C" { status = F_status_set_error(F_parameter); } + if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { + if (data->verbosity != iki_read_verbosity_quiet) { + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, iki_read_long_literal); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, iki_read_long_content); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); + } + + status = F_status_set_error(F_parameter); + } + if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { if (data->verbosity != iki_read_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); @@ -276,6 +290,19 @@ extern "C" { data->mode = iki_read_mode_literal; } else if (data->parameters[iki_read_parameter_object].result == f_console_result_found) { + if (data->parameters[iki_read_parameter_content].result == f_console_result_found) { + if (data->verbosity != iki_read_verbosity_quiet) { + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, data->context.error, data->context.reset, "ERROR: Cannot specify the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, iki_read_long_object); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameter with the '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, iki_read_long_content); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' parameter."); + } + + status = F_status_set_error(F_parameter); + } + if (data->parameters[iki_read_parameter_total].result == f_console_result_found) { if (data->verbosity != iki_read_verbosity_quiet) { fprintf(f_type_error, "%c", f_string_eol[0]); @@ -295,6 +322,7 @@ extern "C" { data->mode = iki_read_mode_total; } else { + // this is the default behavior, so there is no reason to check for the -c/--content parameter. data->mode = iki_read_mode_content; } diff --git a/level_3/iki_read/c/iki_read.h b/level_3/iki_read/c/iki_read.h index 0d451f6..d47119b 100644 --- a/level_3/iki_read/c/iki_read.h +++ b/level_3/iki_read/c/iki_read.h @@ -77,6 +77,7 @@ extern "C" { }; #define iki_read_short_at "a" + #define iki_read_short_content "c" #define iki_read_short_line "l" #define iki_read_short_literal "L" #define iki_read_short_name "n" @@ -86,6 +87,7 @@ extern "C" { #define iki_read_short_whole "w" #define iki_read_long_at "at" + #define iki_read_long_content "content" #define iki_read_long_line "line" #define iki_read_long_literal "literal" #define iki_read_long_name "name" @@ -104,6 +106,7 @@ extern "C" { iki_read_parameter_version, iki_read_parameter_at, + iki_read_parameter_content, iki_read_parameter_line, iki_read_parameter_literal, iki_read_parameter_name, @@ -123,6 +126,7 @@ extern "C" { f_console_parameter_t_initialize(f_console_standard_short_verbose, f_console_standard_long_verbose, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, 0, f_console_type_inverse), \ f_console_parameter_t_initialize(iki_read_short_at, iki_read_long_at, 0, 1, f_console_type_normal), \ + f_console_parameter_t_initialize(iki_read_short_content, iki_read_long_content, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(iki_read_short_line, iki_read_long_line, 0, 1, f_console_type_normal), \ f_console_parameter_t_initialize(iki_read_short_literal, iki_read_long_literal, 0, 0, f_console_type_normal), \ f_console_parameter_t_initialize(iki_read_short_name, iki_read_long_name, 0, 1, f_console_type_normal), \ @@ -132,7 +136,7 @@ extern "C" { f_console_parameter_t_initialize(iki_read_short_total, iki_read_long_total, 0, 0, f_console_type_normal), \ } - #define iki_read_total_parameters 15 + #define iki_read_total_parameters 16 #endif // _di_iki_read_defines_ #ifndef _di_iki_read_substitution_t_ -- 1.8.3.1