Changed usage message so that it is more compact (and slightly
less informative). It's important that it be able to fit on one screen. git-svn-id: https://pandoc.googlecode.com/svn/trunk@351 788f1e2b-df1e-0410-8736-df70ead52e1b
This commit is contained in:
parent
cf53a18bc1
commit
68122303c0
1 changed files with 32 additions and 34 deletions
66
src/Main.hs
66
src/Main.hs
|
@ -144,75 +144,73 @@ options =
|
||||||
(ReqArg
|
(ReqArg
|
||||||
(\arg opt -> return opt { optReader = map toLower arg })
|
(\arg opt -> return opt { optReader = map toLower arg })
|
||||||
"FORMAT")
|
"FORMAT")
|
||||||
("Input format (" ++ (joinWithSep ", " (map fst readers)) ++
|
"" -- ("(" ++ (joinWithSep ", " (map fst readers)) ++ ")")
|
||||||
")")
|
|
||||||
|
|
||||||
, Option "tw" ["to","write"]
|
, Option "tw" ["to","write"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
(\arg opt -> return opt { optWriter = map toLower arg })
|
(\arg opt -> return opt { optWriter = map toLower arg })
|
||||||
"FORMAT")
|
"FORMAT")
|
||||||
("Output format (" ++ (joinWithSep ", " (map fst writers)) ++
|
"" -- ("(" ++ (joinWithSep ", " (map fst writers)) ++ ")")
|
||||||
")")
|
|
||||||
|
|
||||||
, Option "s" ["standalone"]
|
, Option "s" ["standalone"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optStandalone = True }))
|
(\opt -> return opt { optStandalone = True }))
|
||||||
"Include needed header and footer on output"
|
"" -- "Include needed header and footer on output"
|
||||||
|
|
||||||
, Option "o" ["output"]
|
, Option "o" ["output"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
(\arg opt -> return opt { optOutputFile = arg })
|
(\arg opt -> return opt { optOutputFile = arg })
|
||||||
"FILENAME")
|
"FILENAME")
|
||||||
"Name of output file"
|
"" -- "Name of output file"
|
||||||
|
|
||||||
, Option "p" ["preserve-tabs"]
|
, Option "p" ["preserve-tabs"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optPreserveTabs = True }))
|
(\opt -> return opt { optPreserveTabs = True }))
|
||||||
"Preserve tabs instead of converting to spaces"
|
"" -- "Preserve tabs instead of converting to spaces"
|
||||||
|
|
||||||
, Option "" ["tab-stop"]
|
, Option "" ["tab-stop"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
(\arg opt -> return opt { optTabStop = (read arg) } )
|
(\arg opt -> return opt { optTabStop = (read arg) } )
|
||||||
"TABSTOP")
|
"TABSTOP")
|
||||||
"Tab stop (default 4)"
|
"" -- "Tab stop (default 4)"
|
||||||
|
|
||||||
, Option "" ["strict"]
|
, Option "" ["strict"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optStrict = True } ))
|
(\opt -> return opt { optStrict = True } ))
|
||||||
"Use strict markdown syntax with no extensions"
|
"" -- "Use strict markdown syntax with no extensions"
|
||||||
|
|
||||||
, Option "R" ["parse-raw"]
|
, Option "R" ["parse-raw"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optParseRaw = True }))
|
(\opt -> return opt { optParseRaw = True }))
|
||||||
"Parse untranslatable HTML codes and LaTeX environments as raw"
|
"" -- "Parse untranslatable HTML codes and LaTeX environments as raw"
|
||||||
|
|
||||||
, Option "S" ["smart"]
|
, Option "S" ["smart"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optSmart = True }))
|
(\opt -> return opt { optSmart = True }))
|
||||||
"Use smart quotes, dashes, and ellipses in HTML output"
|
"" -- "Use smart quotes, dashes, and ellipses in HTML output"
|
||||||
|
|
||||||
, Option "m" ["asciimathml"]
|
, Option "m" ["asciimathml"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optASCIIMathML = True,
|
(\opt -> return opt { optASCIIMathML = True,
|
||||||
optStandalone = True }))
|
optStandalone = True }))
|
||||||
"Use ASCIIMathML script in html output"
|
"" -- "Use ASCIIMathML script in html output"
|
||||||
|
|
||||||
, Option "i" ["incremental"]
|
, Option "i" ["incremental"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optIncremental = True }))
|
(\opt -> return opt { optIncremental = True }))
|
||||||
"Make list items display incrementally in S5"
|
"" -- "Make list items display incrementally in S5"
|
||||||
|
|
||||||
, Option "N" ["number-sections"]
|
, Option "N" ["number-sections"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optNumberSections = True }))
|
(\opt -> return opt { optNumberSections = True }))
|
||||||
"Number sections in LaTeX"
|
"" -- "Number sections in LaTeX"
|
||||||
|
|
||||||
, Option "c" ["css"]
|
, Option "c" ["css"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
(\arg opt -> return opt { optCSS = arg,
|
(\arg opt -> return opt { optCSS = arg,
|
||||||
optStandalone = True })
|
optStandalone = True })
|
||||||
"CSS")
|
"CSS")
|
||||||
"Link to CSS style sheet"
|
"" -- "Link to CSS style sheet"
|
||||||
|
|
||||||
, Option "H" ["include-in-header"]
|
, Option "H" ["include-in-header"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
|
@ -221,7 +219,7 @@ options =
|
||||||
return opt { optIncludeInHeader = text,
|
return opt { optIncludeInHeader = text,
|
||||||
optStandalone = True })
|
optStandalone = True })
|
||||||
"FILENAME")
|
"FILENAME")
|
||||||
"File to include at end of header (implies -s)"
|
"" -- "File to include at end of header (implies -s)"
|
||||||
|
|
||||||
, Option "B" ["include-before-body"]
|
, Option "B" ["include-before-body"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
|
@ -229,7 +227,7 @@ options =
|
||||||
text <- readFile arg
|
text <- readFile arg
|
||||||
return opt { optIncludeBeforeBody = text })
|
return opt { optIncludeBeforeBody = text })
|
||||||
"FILENAME")
|
"FILENAME")
|
||||||
"File to include before document body"
|
"" -- "File to include before document body"
|
||||||
|
|
||||||
, Option "A" ["include-after-body"]
|
, Option "A" ["include-after-body"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
|
@ -237,7 +235,7 @@ options =
|
||||||
text <- readFile arg
|
text <- readFile arg
|
||||||
return opt { optIncludeAfterBody = text })
|
return opt { optIncludeAfterBody = text })
|
||||||
"FILENAME")
|
"FILENAME")
|
||||||
"File to include after document body"
|
"" -- "File to include after document body"
|
||||||
|
|
||||||
, Option "C" ["custom-header"]
|
, Option "C" ["custom-header"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
|
@ -246,14 +244,14 @@ options =
|
||||||
return opt { optCustomHeader = text,
|
return opt { optCustomHeader = text,
|
||||||
optStandalone = True })
|
optStandalone = True })
|
||||||
"FILENAME")
|
"FILENAME")
|
||||||
"File to use for custom header (implies -s)"
|
"" -- "File to use for custom header (implies -s)"
|
||||||
|
|
||||||
, Option "T" ["title-prefix"]
|
, Option "T" ["title-prefix"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
(\arg opt -> return opt { optTitlePrefix = arg,
|
(\arg opt -> return opt { optTitlePrefix = arg,
|
||||||
optStandalone = True })
|
optStandalone = True })
|
||||||
"STRING")
|
"STRING")
|
||||||
"String to prefix to HTML window title"
|
"" -- "String to prefix to HTML window title"
|
||||||
|
|
||||||
, Option "D" ["print-default-header"]
|
, Option "D" ["print-default-header"]
|
||||||
(ReqArg
|
(ReqArg
|
||||||
|
@ -264,12 +262,12 @@ options =
|
||||||
hPutStr stdout header
|
hPutStr stdout header
|
||||||
exitWith ExitSuccess)
|
exitWith ExitSuccess)
|
||||||
"FORMAT")
|
"FORMAT")
|
||||||
"Print default header for FORMAT"
|
"" -- "Print default header for FORMAT"
|
||||||
|
|
||||||
, Option "d" ["debug"]
|
, Option "d" ["debug"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\opt -> return opt { optDebug = True }))
|
(\opt -> return opt { optDebug = True }))
|
||||||
"Print debug messages to stderr, output to stdout"
|
"" -- "Print debug messages to stderr, output to stdout"
|
||||||
|
|
||||||
, Option "v" ["version"]
|
, Option "v" ["version"]
|
||||||
(NoArg
|
(NoArg
|
||||||
|
@ -278,24 +276,25 @@ options =
|
||||||
hPutStrLn stderr (prg ++ " " ++ version ++
|
hPutStrLn stderr (prg ++ " " ++ version ++
|
||||||
copyrightMessage)
|
copyrightMessage)
|
||||||
exitWith $ ExitFailure 2))
|
exitWith $ ExitFailure 2))
|
||||||
"Print version"
|
"" -- "Print version"
|
||||||
|
|
||||||
, Option "h" ["help"]
|
, Option "h" ["help"]
|
||||||
(NoArg
|
(NoArg
|
||||||
(\_ -> do
|
(\_ -> do
|
||||||
prg <- getProgName
|
prg <- getProgName
|
||||||
hPutStr stderr (reformatUsageInfo $
|
hPutStr stderr (usageMessage prg options)
|
||||||
usageInfo (prg ++ " [OPTIONS] [FILES]") options)
|
|
||||||
exitWith $ ExitFailure 2))
|
exitWith $ ExitFailure 2))
|
||||||
"Show help"
|
"" -- "Show help"
|
||||||
]
|
]
|
||||||
|
|
||||||
-- Reformat usage message so it doesn't wrap illegibly
|
-- Returns usage message
|
||||||
reformatUsageInfo :: String -> String
|
usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
|
||||||
reformatUsageInfo = gsub " *--" " --" .
|
usageMessage programName options = usageInfo
|
||||||
gsub "(-[A-Za-z0-9]) *--" "\\1, --" .
|
(programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
|
||||||
gsub " *([^- ])" "\n\t\\1"
|
joinWithSep ", " (map fst readers) ++ "\nOutput formats: " ++
|
||||||
|
joinWithSep ", " (map fst writers) ++ "\nOptions:")
|
||||||
|
options
|
||||||
|
|
||||||
-- Determine default reader based on source file extensions
|
-- Determine default reader based on source file extensions
|
||||||
defaultReaderName :: [String] -> String
|
defaultReaderName :: [String] -> String
|
||||||
defaultReaderName [] = "markdown"
|
defaultReaderName [] = "markdown"
|
||||||
|
@ -343,8 +342,7 @@ main = do
|
||||||
then do
|
then do
|
||||||
name <- getProgName
|
name <- getProgName
|
||||||
mapM (\e -> hPutStrLn stderr e) errors
|
mapM (\e -> hPutStrLn stderr e) errors
|
||||||
hPutStrLn stderr (reformatUsageInfo $
|
hPutStr stderr (usageMessage name options)
|
||||||
usageInfo (name ++ " [OPTIONS] [FILES]") options)
|
|
||||||
exitWith $ ExitFailure 2
|
exitWith $ ExitFailure 2
|
||||||
else
|
else
|
||||||
return ()
|
return ()
|
||||||
|
|
Loading…
Reference in a new issue