]> Kevux Git Server - fll/commitdiff
Cleanup: add -c/--content for consistency to iki_read.
authorKevin Day <thekevinday@gmail.com>
Sat, 19 Sep 2020 03:20:27 +0000 (22:20 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 19 Sep 2020 03:20:27 +0000 (22:20 -0500)
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
level_3/iki_read/c/iki_read.h

index 4d16762872d5fe4097d87488bffbdd0b9c7daf22..3229389c99dce951be5f4884ef5eb1043a70819e 100644 (file)
@@ -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;
         }
 
index 0d451f614023976b6f8934c69d76dc10daaa0c64..d47119bf6baa9e69ba4a2e21d220a3b6da3c3e82 100644 (file)
@@ -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_