xmlwf_helpgen.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #! /usr/bin/env python3
  2. # __ __ _
  3. # ___\ \/ /_ __ __ _| |_
  4. # / _ \\ /| '_ \ / _` | __|
  5. # | __// \| |_) | (_| | |_
  6. # \___/_/\_\ .__/ \__,_|\__|
  7. # |_| XML parser
  8. #
  9. # Copyright (c) 2019 Expat development team
  10. # Licensed under the MIT license:
  11. #
  12. # Permission is hereby granted, free of charge, to any person obtaining
  13. # a copy of this software and associated documentation files (the
  14. # "Software"), to deal in the Software without restriction, including
  15. # without limitation the rights to use, copy, modify, merge, publish,
  16. # distribute, sublicense, and/or sell copies of the Software, and to permit
  17. # persons to whom the Software is furnished to do so, subject to the
  18. # following conditions:
  19. #
  20. # The above copyright notice and this permission notice shall be included
  21. # in all copies or substantial portions of the Software.
  22. #
  23. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  26. # NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  27. # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  28. # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  29. # USE OR OTHER DEALINGS IN THE SOFTWARE.
  30. import argparse
  31. epilog = """
  32. libexpat is software libre, licensed under the MIT license.
  33. Please report bugs at https://github.com/libexpat/libexpat/issues. Thank you!
  34. """
  35. parser = argparse.ArgumentParser(prog='xmlwf', add_help=False,
  36. description='xmlwf - Determines if an XML document is well-formed',
  37. formatter_class=argparse.RawTextHelpFormatter,
  38. epilog=epilog)
  39. input_related = parser.add_argument_group('input control arguments')
  40. input_related.add_argument('-s', action='store_true', help='print an error if the document is not [s]tandalone')
  41. input_related.add_argument('-n', action='store_true', help='enable [n]amespace processing')
  42. input_related.add_argument('-p', action='store_true', help='enable processing external DTDs and [p]arameter entities')
  43. input_related.add_argument('-x', action='store_true', help='enable processing of e[x]ternal entities')
  44. input_related.add_argument('-e', action='store', metavar='ENCODING', help='override any in-document [e]ncoding declaration')
  45. input_related.add_argument('-w', action='store_true', help='enable support for [W]indows code pages')
  46. input_related.add_argument('-r', action='store_true', help='disable memory-mapping and use normal file [r]ead IO calls instead')
  47. output_related = parser.add_argument_group('output control arguments')
  48. output_related.add_argument('-d', action='store', metavar='DIRECTORY', help='output [d]estination directory')
  49. output_mode = output_related.add_mutually_exclusive_group()
  50. output_mode.add_argument('-c', action='store_true', help='write a [c]opy of input XML, not canonical XML')
  51. output_mode.add_argument('-m', action='store_true', help='write [m]eta XML, not canonical XML')
  52. output_mode.add_argument('-t', action='store_true', help='write no XML output for [t]iming of plain parsing')
  53. output_related.add_argument('-N', action='store_true', help='enable adding doctype and [n]otation declarations')
  54. parser.add_argument('files', metavar='FILE', nargs='*', help='files to process (default: STDIN)')
  55. info = parser.add_argument_group('info arguments')
  56. info = info.add_mutually_exclusive_group()
  57. info.add_argument('-h', action='store_true', help='show this [h]elp message and exit')
  58. info.add_argument('-v', action='store_true', help='show program\'s [v]ersion number and exit')
  59. if __name__ == '__main__':
  60. parser.print_help()