1355071Sdelphij#! /usr/bin/env python3
2355071Sdelphij#                          __  __            _
3355071Sdelphij#                       ___\ \/ /_ __   __ _| |_
4355071Sdelphij#                      / _ \\  /| '_ \ / _` | __|
5355071Sdelphij#                     |  __//  \| |_) | (_| | |_
6355071Sdelphij#                      \___/_/\_\ .__/ \__,_|\__|
7355071Sdelphij#                               |_| XML parser
8355071Sdelphij#
9355071Sdelphij# Copyright (c) 2019 Expat development team
10355071Sdelphij# Licensed under the MIT license:
11355071Sdelphij#
12355071Sdelphij# Permission is  hereby granted,  free of charge,  to any  person obtaining
13355071Sdelphij# a  copy  of  this  software   and  associated  documentation  files  (the
14355071Sdelphij# "Software"),  to  deal in  the  Software  without restriction,  including
15355071Sdelphij# without  limitation the  rights  to use,  copy,  modify, merge,  publish,
16355071Sdelphij# distribute, sublicense, and/or sell copies of the Software, and to permit
17355071Sdelphij# persons  to whom  the Software  is  furnished to  do so,  subject to  the
18355071Sdelphij# following conditions:
19355071Sdelphij#
20355071Sdelphij# The above copyright  notice and this permission notice  shall be included
21355071Sdelphij# in all copies or substantial portions of the Software.
22355071Sdelphij#
23355071Sdelphij# THE  SOFTWARE  IS  PROVIDED  "AS  IS",  WITHOUT  WARRANTY  OF  ANY  KIND,
24355071Sdelphij# EXPRESS  OR IMPLIED,  INCLUDING  BUT  NOT LIMITED  TO  THE WARRANTIES  OF
25355071Sdelphij# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
26355071Sdelphij# NO EVENT SHALL THE AUTHORS OR  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
27355071Sdelphij# DAMAGES OR  OTHER LIABILITY, WHETHER  IN AN  ACTION OF CONTRACT,  TORT OR
28355071Sdelphij# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
29355071Sdelphij# USE OR OTHER DEALINGS IN THE SOFTWARE.
30355071Sdelphij
31355071Sdelphijimport argparse
32355071Sdelphij
33355071Sdelphijepilog = """
34355071Sdelphijlibexpat is software libre, licensed under the MIT license.
35355071SdelphijPlease report bugs at https://github.com/libexpat/libexpat/issues.  Thank you!
36355071Sdelphij"""
37355071Sdelphij
38355071Sdelphijparser = argparse.ArgumentParser(prog='xmlwf', add_help=False,
39355071Sdelphij                                 description='xmlwf - Determines if an XML document is well-formed',
40355071Sdelphij                                 formatter_class=argparse.RawTextHelpFormatter,
41355071Sdelphij                                 epilog=epilog)
42355071Sdelphij
43355071Sdelphijinput_related = parser.add_argument_group('input control arguments')
44355071Sdelphijinput_related.add_argument('-s', action='store_true', help='print an error if the document is not [s]tandalone')
45355071Sdelphijinput_related.add_argument('-n', action='store_true', help='enable [n]amespace processing')
46355071Sdelphijinput_related.add_argument('-p', action='store_true', help='enable processing external DTDs and [p]arameter entities')
47355071Sdelphijinput_related.add_argument('-x', action='store_true', help='enable processing of e[x]ternal entities')
48355071Sdelphijinput_related.add_argument('-e', action='store', metavar='ENCODING', help='override any in-document [e]ncoding declaration')
49355071Sdelphijinput_related.add_argument('-w', action='store_true', help='enable support for [W]indows code pages')
50355071Sdelphijinput_related.add_argument('-r', action='store_true', help='disable memory-mapping and use normal file [r]ead IO calls instead')
51355071Sdelphij
52355071Sdelphijoutput_related = parser.add_argument_group('output control arguments')
53355071Sdelphijoutput_related.add_argument('-d', action='store', metavar='DIRECTORY', help='output [d]estination directory')
54355071Sdelphijoutput_mode = output_related.add_mutually_exclusive_group()
55355071Sdelphijoutput_mode.add_argument('-c', action='store_true', help='write a [c]opy of input XML, not canonical XML')
56355071Sdelphijoutput_mode.add_argument('-m', action='store_true', help='write [m]eta XML, not canonical XML')
57355071Sdelphijoutput_mode.add_argument('-t', action='store_true', help='write no XML output for [t]iming of plain parsing')
58355071Sdelphijoutput_related.add_argument('-N', action='store_true', help='enable adding doctype and [n]otation declarations')
59355071Sdelphij
60355071Sdelphijparser.add_argument('files', metavar='FILE', nargs='*', help='files to process (default: STDIN)')
61355071Sdelphij
62355071Sdelphijinfo = parser.add_argument_group('info arguments')
63355071Sdelphijinfo = info.add_mutually_exclusive_group()
64355071Sdelphijinfo.add_argument('-h', action='store_true', help='show this [h]elp message and exit')
65355071Sdelphijinfo.add_argument('-v', action='store_true', help='show program\'s [v]ersion number and exit')
66355071Sdelphij
67355071Sdelphij
68355071Sdelphijif __name__ == '__main__':
69355071Sdelphij    parser.print_help()
70