From e0f42bcaba2cdf82dc36f7b835fbf2a9ce6c3e73 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Sat, 31 Oct 2015 17:33:43 +0800 Subject: [PATCH] Prototype (undocument) -help-option argument added to console app. --- console/tidy.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/console/tidy.c b/console/tidy.c index 430df55..9d3fc1e 100644 --- a/console/tidy.c +++ b/console/tidy.c @@ -878,6 +878,26 @@ static void optionhelp( TidyDoc tdoc ) ForEachSortedOption( tdoc, printOption ); } +static void optiondescribe( TidyDoc tdoc, char *tag ) +{ + printf( "\nNote this help function is UNDOCUMENTED, and still needs work.\n" ); + + printf( "\n`%s`\n\n", tag ); + + TidyOptionId topt = tidyOptGetIdForName( tag ); + + char *result = NULL; + if (topt < N_TIDY_OPTIONS) + { + result = (char*)tidyOptGetDoc( tdoc, tidyGetOption( tdoc, topt ) ); + } else + { + result = "Unknown option."; + } + + printf( "%s\n\n", result ); +} + static void printOptionValues( TidyDoc ARG_UNUSED(tdoc), TidyOption topt, OptionDesc *d ) @@ -1096,6 +1116,19 @@ int main( int argc, char** argv ) tidyRelease( tdoc ); return 0; /* success */ } + else if ( strcasecmp(arg, "help-option") == 0 ) + { + if ( argc >= 3) + { + optiondescribe( tdoc, argv[2] ); + } + else + { + printf( "%s", "Tidy option name must be specified.\n"); + } + tidyRelease( tdoc ); + return 0; /* success */ + } else if ( strcasecmp(arg, "xml-config") == 0 ) { XMLoptionhelp( tdoc );