[PATCH setup 2/9] Alphabetically sort options in usage help

Jon Turney jon.turney@dronecode.org.uk
Tue Jun 6 11:54:00 GMT 2017


---
 libgetopt++/src/OptionSet.cc | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libgetopt++/src/OptionSet.cc b/libgetopt++/src/OptionSet.cc
index bc3f018..82e1253 100644
--- a/libgetopt++/src/OptionSet.cc
+++ b/libgetopt++/src/OptionSet.cc
@@ -314,9 +314,16 @@ OptionSet::Register (Option * anOption)
     options.push_back(anOption);
 }
 
+static bool
+comp_long_option(const Option *a, const Option *b)
+{
+  return (a->longOption().compare(b->longOption()) < 0);
+}
+
 void
 OptionSet::ParameterUsage (ostream &aStream)
 {
+    std::sort(options.begin(), options.end(), comp_long_option);
     for_each (options.begin(), options.end(), DefaultFormatter (aStream));
 }
 
-- 
2.12.3



More information about the Cygwin-apps mailing list