module Text.XML.HXT.Arrow.XmlOptions
where
import Text.XML.HXT.DOM.Interface
import Text.XML.HXT.Arrow.XmlState.TypeDefs
import Text.XML.HXT.Arrow.XmlState.SystemConfig
import Data.Maybe
import System.Console.GetOpt
inputOptions :: [OptDescr SysConfig]
inputOptions :: [OptDescr SysConfig]
inputOptions
= [ [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"t" [[Char]
a_trace] ((Maybe [Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. (Maybe [Char] -> a) -> [Char] -> ArgDescr a
OptArg Maybe [Char] -> SysConfig
trc [Char]
"LEVEL") [Char]
"trace level (0-4), default 1"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"p" [[Char]
a_proxy] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> SysConfig
withProxy [Char]
"PROXY") [Char]
"proxy for http access (e.g. \"www-cache:3128\")"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_redirect] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withRedirect Bool
True)) [Char]
"automatically follow redirected URIs"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_no_redirect] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withRedirect Bool
False)) [Char]
"switch off following redirected URIs"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_default_baseuri] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> SysConfig
withDefaultBaseURI [Char]
"URI") [Char]
"default base URI, default: \"file:///<cwd>/\""
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"e" [[Char]
a_encoding] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> SysConfig
withInputEncoding [Char]
"CHARSET") ( [Char]
"default document encoding (" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
utf8 [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
", " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
isoLatin1 [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
", " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
usAscii [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
", ...)" )
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_mime_types] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> SysConfig
withMimeTypeFile [Char]
"FILE") [Char]
"set mime type configuration file, e.g. \"/etc/mime.types\""
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_issue_errors] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withErrors Bool
True)) [Char]
"issue all error messages on stderr (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_do_not_issue_errors] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withErrors Bool
False)) [Char]
"ignore all error messages"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_ignore_encoding_errors] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withEncodingErrors Bool
False)) [Char]
"ignore encoding errors"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_ignore_none_xml_contents] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withIgnoreNoneXmlContents Bool
True)) [Char]
"discards all contents of none XML/HTML documents, only the meta info remains in the doc tree"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_accept_mimetypes] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> SysConfig
withMT [Char]
"MIMETYPES") [Char]
"only accept documents matching the given comma separated list of mimetype specs"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"H" [[Char]
a_parse_html] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withParseHTML Bool
True)) [Char]
"parse input as HTML, try to interprete everything as HTML, no validation"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"M" [[Char]
a_parse_by_mimetype] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withParseByMimeType Bool
True)) [Char]
"parse dependent on mime type: text/html as HTML, text/xml and text/xhtml and others as XML, else no parse"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_parse_xml] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withParseHTML Bool
False)) [Char]
"parse input as XML, (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_strict_input] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withStrictInput Bool
True)) [Char]
"read input files strictly, this ensures closing the files correctly even if not read completely"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_issue_warnings] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withWarnings Bool
True)) [Char]
"issue warnings, when parsing HTML (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"Q" [[Char]
a_do_not_issue_warnings] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withWarnings Bool
False)) [Char]
"ignore warnings, when parsing HTML"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_validate] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withValidate Bool
True)) [Char]
"document validation when parsing XML (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"w" [[Char]
a_do_not_validate] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withValidate Bool
False)) [Char]
"only wellformed check, no validation"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_subst_dtd_entities] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withSubstDTDEntities Bool
True)) [Char]
"entities defined in DTD are substituted when parsing XML (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_do_not_subst_dtd_entities] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withSubstDTDEntities Bool
False)) [Char]
"entities defined in DTD are NOT substituted when parsing XML"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_subst_html_entities] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withSubstHTMLEntities Bool
True)) [Char]
"entities defined in XHTML are substituted when parsing XML, only in effect when prev. option is switched off"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_do_not_subst_html_entities] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withSubstHTMLEntities Bool
False)) [Char]
"only entities predefined in XML are substituted when parsing XML (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_canonicalize] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withCanonicalize Bool
True)) [Char]
"canonicalize document, remove DTD, comment, transform CDATA, CharRef's, ... (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"c" [[Char]
a_do_not_canonicalize] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withCanonicalize Bool
False)) [Char]
"do not canonicalize document, don't remove DTD, comment, don't transform CDATA, CharRef's, ..."
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"C" [[Char]
a_preserve_comment] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withPreserveComment Bool
True)) [Char]
"don't remove comments during canonicalisation"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_do_not_preserve_comment] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withPreserveComment Bool
False)) [Char]
"remove comments during canonicalisation (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"n" [[Char]
a_check_namespaces] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withCheckNamespaces Bool
True)) [Char]
"tag tree with namespace information and check namespaces"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_do_not_check_namespaces] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withCheckNamespaces Bool
False)) [Char]
"ignore namespaces (default)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"r" [[Char]
a_remove_whitespace] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withRemoveWS Bool
True)) [Char]
"remove redundant whitespace, simplifies tree and processing"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_do_not_remove_whitespace] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withRemoveWS Bool
False)) [Char]
"don't remove redundant whitespace (default)"
]
where
withMT :: [Char] -> SysConfig
withMT = [[Char]] -> SysConfig
withAcceptedMimeTypes ([[Char]] -> SysConfig)
-> ([Char] -> [[Char]]) -> [Char] -> SysConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [[Char]]
words ([Char] -> [[Char]]) -> ([Char] -> [Char]) -> [Char] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map (\ Char
x -> if Char
x Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
',' then Char
' ' else Char
x)
trc :: Maybe [Char] -> SysConfig
trc = Int -> SysConfig
withTrace (Int -> SysConfig)
-> (Maybe [Char] -> Int) -> Maybe [Char] -> SysConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
0 (Int -> Int) -> (Maybe [Char] -> Int) -> Maybe [Char] -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int -> Int
forall a. Ord a => a -> a -> a
min Int
9 (Int -> Int) -> (Maybe [Char] -> Int) -> Maybe [Char] -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> Int
forall a. Read a => [Char] -> a
read :: String -> Int) ([Char] -> Int) -> (Maybe [Char] -> [Char]) -> Maybe [Char] -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char
'0'Char -> [Char] -> [Char]
forall a. a -> [a] -> [a]
:) ([Char] -> [Char])
-> (Maybe [Char] -> [Char]) -> Maybe [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Bool) -> [Char] -> [Char]
forall a. (a -> Bool) -> [a] -> [a]
filter (Char -> [Char] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char]
"0123456789") ([Char] -> [Char])
-> (Maybe [Char] -> [Char]) -> Maybe [Char] -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Maybe [Char] -> [Char]
forall a. a -> Maybe a -> a
fromMaybe [Char]
v_1
outputOptions :: [OptDescr SysConfig]
outputOptions :: [OptDescr SysConfig]
outputOptions
= [ [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"f" [[Char]
a_output_file] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg ([Char] -> [Char] -> SysConfig
withSysAttr [Char]
a_output_file) [Char]
"FILE") [Char]
"output file for resulting document (default: stdout)"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"i" [[Char]
a_indent] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withIndent Bool
True)) [Char]
"indent XML output for readability"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"o" [[Char]
a_output_encoding] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg [Char] -> SysConfig
withOutputEncoding [Char]
"CHARSET") ( [Char]
"encoding of output (" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
utf8 [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
", " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
isoLatin1 [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
", " [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
usAscii [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char]
")" )
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_output_xml] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg SysConfig
withOutputXML ) [Char]
"output of none ASCII chars as HTMl entity references"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_output_html] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg SysConfig
withOutputHTML ) [Char]
"output of none ASCII chars as HTMl entity references"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_output_xhtml] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg SysConfig
withOutputXHTML ) [Char]
"output of HTML elements with empty content (script, ...) done in format <elem...></elem> instead of <elem/>"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_output_plain] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg SysConfig
withOutputPLAIN ) [Char]
"output of HTML elements with empty content (script, ...) done in format <elem...></elem> instead of <elem/>"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_no_xml_pi] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withXmlPi Bool
False)) ([Char]
"output without <?xml ...?> processing instruction, useful in combination with --" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++ [Char] -> [Char]
forall a. Show a => a -> [Char]
show [Char]
a_output_html)
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_no_empty_elem_for] (([Char] -> SysConfig) -> [Char] -> ArgDescr SysConfig
forall a. ([Char] -> a) -> [Char] -> ArgDescr a
ReqArg ([[Char]] -> SysConfig
withNoEmptyElemFor ([[Char]] -> SysConfig)
-> ([Char] -> [[Char]]) -> [Char] -> SysConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> [[Char]]
words') [Char]
"NAMES") [Char]
"output of empty elements done in format <elem...></elem> only for given list of element names"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_add_default_dtd] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withAddDefaultDTD Bool
True)) [Char]
"add the document type declaration given in the input document"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_text_mode] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withTextMode Bool
True)) [Char]
"output in text mode"
]
where
words' :: [Char] -> [[Char]]
words'
= [Char] -> [[Char]]
words
([Char] -> [[Char]]) -> ([Char] -> [Char]) -> [Char] -> [[Char]]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Char) -> [Char] -> [Char]
forall a b. (a -> b) -> [a] -> [b]
map (\ Char
c -> if Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
',' then Char
' ' else Char
c)
generalOptions :: [OptDescr SysConfig]
generalOptions :: [OptDescr SysConfig]
generalOptions
= [ [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"v" [[Char]
a_verbose] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg ([Char] -> [Char] -> SysConfig
withSysAttr [Char]
a_verbose [Char]
v_1)) [Char]
"verbose output"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"h?" [[Char]
a_help] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg ([Char] -> [Char] -> SysConfig
withSysAttr [Char]
a_help [Char]
v_1)) [Char]
"this message"
]
versionOptions :: [OptDescr SysConfig]
versionOptions :: [OptDescr SysConfig]
versionOptions
= [ [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"V" [[Char]
a_version] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg ([Char] -> [Char] -> SysConfig
withSysAttr [Char]
a_version [Char]
v_1)) [Char]
"show program version"
]
showOptions :: [OptDescr SysConfig]
showOptions :: [OptDescr SysConfig]
showOptions
= [ [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_show_tree] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withShowTree Bool
True)) [Char]
"output tree representation instead of document source"
, [Char]
-> [[Char]] -> ArgDescr SysConfig -> [Char] -> OptDescr SysConfig
forall a. [Char] -> [[Char]] -> ArgDescr a -> [Char] -> OptDescr a
Option [Char]
"" [[Char]
a_show_haskell] (SysConfig -> ArgDescr SysConfig
forall a. a -> ArgDescr a
NoArg (Bool -> SysConfig
withShowHaskell Bool
True)) [Char]
"output internal Haskell representation instead of document source"
]
a_accept_mimetypes,
a_add_default_dtd,
a_canonicalize,
a_check_namespaces,
a_collect_errors,
a_default_baseuri,
a_do_not_canonicalize,
a_do_not_check_namespaces,
a_do_not_issue_errors,
a_do_not_issue_warnings,
a_do_not_preserve_comment,
a_do_not_remove_whitespace,
a_do_not_subst_dtd_entities,
a_do_not_subst_html_entities,
a_do_not_validate,
a_error,
a_error_log,
a_help,
a_if_modified_since,
a_if_unmodified_since,
a_ignore_encoding_errors,
a_ignore_none_xml_contents,
a_indent,
a_issue_errors,
a_issue_warnings,
a_mime_types,
a_no_empty_elements,
a_no_empty_elem_for,
a_no_redirect,
a_no_xml_pi,
a_output_file,
a_output_xml,
a_output_html,
a_output_xhtml,
a_output_plain,
a_parse_by_mimetype,
a_parse_html,
a_parse_xml,
a_preserve_comment,
a_proxy,
a_redirect,
a_remove_whitespace,
a_show_haskell,
a_show_tree,
a_strict_input,
a_subst_dtd_entities,
a_subst_html_entities,
a_text_mode,
a_trace,
a_validate,
a_verbose :: String
a_accept_mimetypes :: [Char]
a_accept_mimetypes = [Char]
"accept-mimetypes"
a_add_default_dtd :: [Char]
a_add_default_dtd = [Char]
"add-default-dtd"
a_canonicalize :: [Char]
a_canonicalize = [Char]
"canonicalize"
a_check_namespaces :: [Char]
a_check_namespaces = [Char]
"check-namespaces"
a_collect_errors :: [Char]
a_collect_errors = [Char]
"collect-errors"
a_default_baseuri :: [Char]
a_default_baseuri = [Char]
"default-base-URI"
a_do_not_canonicalize :: [Char]
a_do_not_canonicalize = [Char]
"do-not-canonicalize"
a_do_not_check_namespaces :: [Char]
a_do_not_check_namespaces = [Char]
"do-not-check-namespaces"
a_do_not_issue_errors :: [Char]
a_do_not_issue_errors = [Char]
"do-not-issue-errors"
a_do_not_issue_warnings :: [Char]
a_do_not_issue_warnings = [Char]
"do-not-issue-warnings"
= [Char]
"do-not-preserve-comment"
a_do_not_remove_whitespace :: [Char]
a_do_not_remove_whitespace = [Char]
"do-not-remove-whitespace"
a_do_not_subst_dtd_entities :: [Char]
a_do_not_subst_dtd_entities = [Char]
"do-not-subst-dtd-entities"
a_do_not_subst_html_entities :: [Char]
a_do_not_subst_html_entities = [Char]
"do-not-subst-html-entities"
a_do_not_validate :: [Char]
a_do_not_validate = [Char]
"do-not-validate"
a_error :: [Char]
a_error = [Char]
"error"
a_error_log :: [Char]
a_error_log = [Char]
"errorLog"
a_help :: [Char]
a_help = [Char]
"help"
a_if_modified_since :: [Char]
a_if_modified_since = [Char]
"if-modified-since"
a_if_unmodified_since :: [Char]
a_if_unmodified_since = [Char]
"if-unmodified-since"
a_ignore_encoding_errors :: [Char]
a_ignore_encoding_errors = [Char]
"ignore-encoding-errors"
a_ignore_none_xml_contents :: [Char]
a_ignore_none_xml_contents = [Char]
"ignore-none-xml-contents"
a_indent :: [Char]
a_indent = [Char]
"indent"
a_issue_warnings :: [Char]
a_issue_warnings = [Char]
"issue-warnings"
a_issue_errors :: [Char]
a_issue_errors = [Char]
"issue-errors"
a_mime_types :: [Char]
a_mime_types = [Char]
"mimetypes"
a_no_empty_elements :: [Char]
a_no_empty_elements = [Char]
"no-empty-elements"
a_no_empty_elem_for :: [Char]
a_no_empty_elem_for = [Char]
"no-empty-elem-for"
a_no_redirect :: [Char]
a_no_redirect = [Char]
"no-redirect"
a_no_xml_pi :: [Char]
a_no_xml_pi = [Char]
"no-xml-pi"
a_output_file :: [Char]
a_output_file = [Char]
"output-file"
a_output_html :: [Char]
a_output_html = [Char]
"output-html"
a_output_xhtml :: [Char]
a_output_xhtml = [Char]
"output-xhtml"
a_output_xml :: [Char]
a_output_xml = [Char]
"output-xml"
a_output_plain :: [Char]
a_output_plain = [Char]
"output-plain"
a_parse_by_mimetype :: [Char]
a_parse_by_mimetype = [Char]
"parse-by-mimetype"
a_parse_html :: [Char]
a_parse_html = [Char]
"parse-html"
a_parse_xml :: [Char]
a_parse_xml = [Char]
"parse-xml"
= [Char]
"preserve-comment"
a_proxy :: [Char]
a_proxy = [Char]
"proxy"
a_redirect :: [Char]
a_redirect = [Char]
"redirect"
a_remove_whitespace :: [Char]
a_remove_whitespace = [Char]
"remove-whitespace"
a_show_haskell :: [Char]
a_show_haskell = [Char]
"show-haskell"
a_show_tree :: [Char]
a_show_tree = [Char]
"show-tree"
a_strict_input :: [Char]
a_strict_input = [Char]
"strict-input"
a_subst_dtd_entities :: [Char]
a_subst_dtd_entities = [Char]
"subst-dtd-entities"
a_subst_html_entities :: [Char]
a_subst_html_entities = [Char]
"subst-html-entities"
a_text_mode :: [Char]
a_text_mode = [Char]
"text-mode"
a_trace :: [Char]
a_trace = [Char]
"trace"
a_validate :: [Char]
a_validate = [Char]
"validate"
a_verbose :: [Char]
a_verbose = [Char]
"verbose"
selectOptions :: [String] -> [OptDescr a] -> [OptDescr a]
selectOptions :: [[Char]] -> [OptDescr a] -> [OptDescr a]
selectOptions [[Char]]
ol [OptDescr a]
os
= [[OptDescr a]] -> [OptDescr a]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([[OptDescr a]] -> [OptDescr a])
-> ([[Char]] -> [[OptDescr a]]) -> [[Char]] -> [OptDescr a]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> [OptDescr a]) -> [[Char]] -> [[OptDescr a]]
forall a b. (a -> b) -> [a] -> [b]
map (\ [Char]
on -> (OptDescr a -> Bool) -> [OptDescr a] -> [OptDescr a]
forall a. (a -> Bool) -> [a] -> [a]
filter (\ (Option [Char]
_ [[Char]]
ons ArgDescr a
_ [Char]
_) -> [Char]
on [Char] -> [[Char]] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[Char]]
ons) [OptDescr a]
os) ([[Char]] -> [OptDescr a]) -> [[Char]] -> [OptDescr a]
forall a b. (a -> b) -> a -> b
$ [[Char]]
ol
removeOptions :: [String] -> [OptDescr a] -> [OptDescr a]
removeOptions :: [[Char]] -> [OptDescr a] -> [OptDescr a]
removeOptions [[Char]]
ol [OptDescr a]
os
= (OptDescr a -> Bool) -> [OptDescr a] -> [OptDescr a]
forall a. (a -> Bool) -> [a] -> [a]
filter (\ (Option [Char]
_ [[Char]]
ons ArgDescr a
_ [Char]
_) -> Bool -> Bool
not (Bool -> Bool) -> ([[Char]] -> Bool) -> [[Char]] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char] -> Bool) -> [[Char]] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any ([Char] -> [[Char]] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [[Char]]
ol) ([[Char]] -> Bool) -> [[Char]] -> Bool
forall a b. (a -> b) -> a -> b
$ [[Char]]
ons ) [OptDescr a]
os