From ccd0499c10b1ebf075bc251c4827ab79a6975165 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 23 Nov 2015 11:58:19 +0200 Subject: Change print_short_usage() to print_usage() --- cli/header.cxx | 26 ++++++++++---------------- cli/options.cli | 11 +++++------ cli/source.cxx | 14 ++++---------- 3 files changed, 19 insertions(+), 32 deletions(-) (limited to 'cli') diff --git a/cli/header.cxx b/cli/header.cxx index 76e2626..35097af 100644 --- a/cli/header.cxx +++ b/cli/header.cxx @@ -192,15 +192,12 @@ namespace os << "// Print usage information." << endl << "//" << endl; - if (usage != ut_both) - os << "static void" << endl - << "print_usage (" << options.ostream_type () << "&);" - << endl; - else + os << "static void" << endl + << "print_usage (" << options.ostream_type () << "&);" + << endl; + + if (usage == ut_both) os << "static void" << endl - << "print_short_usage (" << options.ostream_type () << "&);" - << endl - << "static void" << endl << "print_long_usage (" << options.ostream_type () << "&);" << endl; } @@ -341,15 +338,12 @@ generate_header (context& ctx) string const& ost (ctx.options.ostream_type ()); - if (ctx.usage != ut_both) - os << "void" << endl - << n << "usage (" << ost << "&);" - << endl; - else + os << "void" << endl + << n << "usage (" << ost << "&);" + << endl; + + if (ctx.usage == ut_both) os << "void" << endl - << n << "short_usage (" << ost << "&);" - << endl - << "void" << endl << n << "long_usage (" << ost << "&);" << endl; diff --git a/cli/options.cli b/cli/options.cli index 437f848..7f8c138 100644 --- a/cli/options.cli +++ b/cli/options.cli @@ -125,10 +125,10 @@ class options bool --short-usage { "If specified together with \cb{--long-usage}, generate both short - and long usage versions. In this mode, the usage printing functions - are called \cb{print_short_usage()} and \cb{print_long_usage()} and - for the long usage the long documentation string is always used, - even if the short version is provided." + and long usage versions. In this mode, the long usage printing function + is called \cb{print_long_usage()} and in its implementation the long + documentation string is always used, even if the short version is + provided." }; std::string --page-usage @@ -151,8 +151,7 @@ class options \ If both \cb{--long-usage} and \cb{--short-usage} options are specified, - then two functions are generated with the \cb{*short_usage()} and - \cb{*long_usage()} suffixes." + then the long usage function has the \cb{*long_usage()} suffix." }; std::size_t --option-length = 0 diff --git a/cli/source.cxx b/cli/source.cxx index 0258c84..2113034 100644 --- a/cli/source.cxx +++ b/cli/source.cxx @@ -517,10 +517,7 @@ namespace virtual void traverse (type& c) { - const char* t ( - usage != ut_both - ? "" - : usage_ == ut_short ? "short_" : "long_"); + const char* t (usage != ut_both || usage_ == ut_short ? "" : "long_"); os << "// " << escape (c.name ()) << " base" << endl << "//" << endl @@ -751,7 +748,7 @@ namespace // If len is 0 then it means we have no options to print. // os << "void " << name << "::" << endl - << "print_" << (usage == ut_both ? "short_" : "") << "usage (" << + << "print_usage (" << options.ostream_type () << "&" << (len != 0 || b ? " os)" : ")") << "{"; @@ -1083,10 +1080,7 @@ namespace if (para_ == para_text) os << "os << ::std::endl;"; - const char* t ( - usage != ut_both - ? "" - : usage_ == ut_short ? "short_" : "long_"); + const char* t (usage != ut_both || usage_ == ut_short ? "" : "long_"); os << fq_name (c) << "::print_" << t << "usage (os);" << endl; @@ -1136,7 +1130,7 @@ generate_source (context& ctx) { os << "void" << endl - << n << (u == ut_both ? "short_" : "") << "usage (" << ost << "& os)" + << n << "usage (" << ost << "& os)" << "{" << "CLI_POTENTIALLY_UNUSED (os);" << endl; -- cgit v1.1