]> granicus.if.org Git - libexpat/commitdiff
xmlwf: Improve "xmlwf -h" help output
authorSebastian Pipping <sebastian@pipping.org>
Wed, 4 Sep 2019 21:23:29 +0000 (23:23 +0200)
committerSebastian Pipping <sebastian@pipping.org>
Wed, 4 Sep 2019 22:45:14 +0000 (00:45 +0200)
expat/Changes
expat/Makefile.am
expat/xmlwf/xmlwf.c
expat/xmlwf/xmlwf_helpgen.py [new file with mode: 0755]
expat/xmlwf/xmlwf_helpgen.sh [new file with mode: 0755]

index 282780da3d42e78cb2598d2202d9eff48e925c46..d2262c2996221f3411489756df10923daf3b30f7 100644 (file)
@@ -76,6 +76,7 @@ Release x.x.x xxx xxx xx xxxx
        #299 #302  Windows: Replace LoadLibrary hack to access
                     unofficial API function SystemFunction036 (RtlGenRandom)
                     by using official API function rand_s (needs WinXP+)
+                  xmlwf: Make "xmlwf -h" help output more friendly
              #14  Drop an OpenVMS support leftover
     #235 #268 ..
     #270 #310 ..
index b32d9bad2464de4661eab810edcad82a0c472bec..5e1d37dd1a830b8feb05e5f20389381191d560b0 100644 (file)
@@ -76,6 +76,9 @@ EXTRA_DIST = \
     conftools/get-version.sh \
     conftools/PrintPath \
     \
+    xmlwf/xmlwf_helpgen.py \
+    xmlwf/xmlwf_helpgen.sh \
+    \
     Changes \
     README.md \
     \
index 1a755bcd1432772237fd21720cebd7f8fc8cc4e2..e64dbca9464dcac7cb7fcaae9b04a1e30937821f 100644 (file)
@@ -846,7 +846,42 @@ static void
 usage(const XML_Char *prog, int rc) {
   ftprintf(
       stderr,
-      T("usage: %s [-s] [-n] [-p] [-x] [-e encoding] [-w] [-d output-dir] [-c] [-m] [-r] [-t] [-N] [file ...]\n"),
+      /* Generated with:
+       * $ xmlwf/xmlwf_helpgen.sh
+       */
+      /* clang-format off */
+      T("usage: %s [-s] [-n] [-p] [-x] [-e ENCODING] [-w] [-r] [-d DIRECTORY]\n")
+      T("             [-c | -m | -t] [-N] [-h | -v]\n")
+      T("             [FILE [FILE ...]]\n")
+      T("\n")
+      T("xmlwf - Determines if an XML document is well-formed\n")
+      T("\n")
+      T("positional arguments:\n")
+      T("  FILE          files to process (default: STDIN)\n")
+      T("\n")
+      T("input control arguments:\n")
+      T("  -s            print an error if the document is not [s]tandalone\n")
+      T("  -n            enable [n]amespace processing\n")
+      T("  -p            enable processing external DTDs and [p]arameter entities\n")
+      T("  -x            enable processing of e[x]ternal entities\n")
+      T("  -e ENCODING   override any in-document [e]ncoding declaration\n")
+      T("  -w            enable support for [W]indows code pages\n")
+      T("  -r            disable memory-mapping and use normal file [r]ead IO calls instead\n")
+      T("\n")
+      T("output control arguments:\n")
+      T("  -d DIRECTORY  output [d]estination directory\n")
+      T("  -c            write a [c]opy of input XML, not canonical XML\n")
+      T("  -m            write [m]eta XML, not canonical XML\n")
+      T("  -t            write no XML output for [t]iming of plain parsing\n")
+      T("  -N            enable adding doctype and [n]otation declarations\n")
+      T("\n")
+      T("info arguments:\n")
+      T("  -h            show this [h]elp message and exit\n")
+      T("  -v            show program's [v]ersion number and exit\n")
+      T("\n")
+      T("libexpat is software libre, licensed under the MIT license.\n")
+      T("Please report bugs at https://github.com/libexpat/libexpat/issues.  Thank you!\n")
+      , /* clang-format on */
       prog);
   exit(rc);
 }
diff --git a/expat/xmlwf/xmlwf_helpgen.py b/expat/xmlwf/xmlwf_helpgen.py
new file mode 100755 (executable)
index 0000000..0dcb6d3
--- /dev/null
@@ -0,0 +1,69 @@
+#! /usr/bin/env python3
+#                          __  __            _
+#                       ___\ \/ /_ __   __ _| |_
+#                      / _ \\  /| '_ \ / _` | __|
+#                     |  __//  \| |_) | (_| | |_
+#                      \___/_/\_\ .__/ \__,_|\__|
+#                               |_| XML parser
+#
+# Copyright (c) 2019 Expat development team
+# Licensed under the MIT license:
+#
+# Permission is  hereby granted,  free of charge,  to any  person obtaining
+# a  copy  of  this  software   and  associated  documentation  files  (the
+# "Software"),  to  deal in  the  Software  without restriction,  including
+# without  limitation the  rights  to use,  copy,  modify, merge,  publish,
+# distribute, sublicense, and/or sell copies of the Software, and to permit
+# persons  to whom  the Software  is  furnished to  do so,  subject to  the
+# following conditions:
+#
+# The above copyright  notice and this permission notice  shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
+# EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+# NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+# USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+import argparse
+
+epilog = """
+libexpat is software libre, licensed under the MIT license.
+Please report bugs at https://github.com/libexpat/libexpat/issues.  Thank you!
+"""
+
+parser = argparse.ArgumentParser(prog='xmlwf', add_help=False,
+                                 description='xmlwf - Determines if an XML document is well-formed',
+                                 formatter_class=argparse.RawTextHelpFormatter,
+                                 epilog=epilog)
+
+input_related = parser.add_argument_group('input control arguments')
+input_related.add_argument('-s', action='store_true', help='print an error if the document is not [s]tandalone')
+input_related.add_argument('-n', action='store_true', help='enable [n]amespace processing')
+input_related.add_argument('-p', action='store_true', help='enable processing external DTDs and [p]arameter entities')
+input_related.add_argument('-x', action='store_true', help='enable processing of e[x]ternal entities')
+input_related.add_argument('-e', action='store', metavar='ENCODING', help='override any in-document [e]ncoding declaration')
+input_related.add_argument('-w', action='store_true', help='enable support for [W]indows code pages')
+input_related.add_argument('-r', action='store_true', help='disable memory-mapping and use normal file [r]ead IO calls instead')
+
+output_related = parser.add_argument_group('output control arguments')
+output_related.add_argument('-d', action='store', metavar='DIRECTORY', help='output [d]estination directory')
+output_mode = output_related.add_mutually_exclusive_group()
+output_mode.add_argument('-c', action='store_true', help='write a [c]opy of input XML, not canonical XML')
+output_mode.add_argument('-m', action='store_true', help='write [m]eta XML, not canonical XML')
+output_mode.add_argument('-t', action='store_true', help='write no XML output for [t]iming of plain parsing')
+output_related.add_argument('-N', action='store_true', help='enable adding doctype and [n]otation declarations')
+
+parser.add_argument('files', metavar='FILE', nargs='*', help='files to process (default: STDIN)')
+
+info = parser.add_argument_group('info arguments')
+info = info.add_mutually_exclusive_group()
+info.add_argument('-h', action='store_true', help='show this [h]elp message and exit')
+info.add_argument('-v', action='store_true', help='show program\'s [v]ersion number and exit')
+
+
+if __name__ == '__main__':
+    parser.print_help()
diff --git a/expat/xmlwf/xmlwf_helpgen.sh b/expat/xmlwf/xmlwf_helpgen.sh
new file mode 100755 (executable)
index 0000000..ed0765b
--- /dev/null
@@ -0,0 +1,34 @@
+#! /usr/bin/env bash
+#                          __  __            _
+#                       ___\ \/ /_ __   __ _| |_
+#                      / _ \\  /| '_ \ / _` | __|
+#                     |  __//  \| |_) | (_| | |_
+#                      \___/_/\_\ .__/ \__,_|\__|
+#                               |_| XML parser
+#
+# Copyright (c) 2019 Expat development team
+# Licensed under the MIT license:
+#
+# Permission is  hereby granted,  free of charge,  to any  person obtaining
+# a  copy  of  this  software   and  associated  documentation  files  (the
+# "Software"),  to  deal in  the  Software  without restriction,  including
+# without  limitation the  rights  to use,  copy,  modify, merge,  publish,
+# distribute, sublicense, and/or sell copies of the Software, and to permit
+# persons  to whom  the Software  is  furnished to  do so,  subject to  the
+# following conditions:
+#
+# The above copyright  notice and this permission notice  shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
+# EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+# NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+# USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+./xmlwf/xmlwf_helpgen.py | sed \
+        -e 's,usage: xmlwf,usage: %s,' \
+        -e 's,^,      T(",' \
+        -e 's,$,\\n"),'