git.iko.soy/typeable/pandoc
on master help sign in
Changed usage message so that it is more compact (and slightly
6812230fiddlosopher
src/Main.hs+32−34
@@ -144,75 +144,73 @@ options =
144 (ReqArg
144 (ReqArg
145 (\arg opt -> return opt { optReader = map toLower arg })
145 (\arg opt -> return opt { optReader = map toLower arg })
146 "FORMAT")
146 "FORMAT")
147− ("Input format (" ++ (joinWithSep ", " (map fst readers)) ++
147+ "" -- ("(" ++ (joinWithSep ", " (map fst readers)) ++ ")")
148− ")")
149
148
150 , Option "tw" ["to","write"]
149 , Option "tw" ["to","write"]
151 (ReqArg
150 (ReqArg
152 (\arg opt -> return opt { optWriter = map toLower arg })
151 (\arg opt -> return opt { optWriter = map toLower arg })
153 "FORMAT")
152 "FORMAT")
154− ("Output format (" ++ (joinWithSep ", " (map fst writers)) ++
153+ "" -- ("(" ++ (joinWithSep ", " (map fst writers)) ++ ")")
155− ")")
156
154
157 , Option "s" ["standalone"]
155 , Option "s" ["standalone"]
158 (NoArg
156 (NoArg
159 (\opt -> return opt { optStandalone = True }))
157 (\opt -> return opt { optStandalone = True }))
160− "Include needed header and footer on output"
158+ "" -- "Include needed header and footer on output"
161
159
162 , Option "o" ["output"]
160 , Option "o" ["output"]
163 (ReqArg
161 (ReqArg
164 (\arg opt -> return opt { optOutputFile = arg })
162 (\arg opt -> return opt { optOutputFile = arg })
165 "FILENAME")
163 "FILENAME")
166− "Name of output file"
164+ "" -- "Name of output file"
167
165
168 , Option "p" ["preserve-tabs"]
166 , Option "p" ["preserve-tabs"]
169 (NoArg
167 (NoArg
170 (\opt -> return opt { optPreserveTabs = True }))
168 (\opt -> return opt { optPreserveTabs = True }))
171− "Preserve tabs instead of converting to spaces"
169+ "" -- "Preserve tabs instead of converting to spaces"
172
170
173 , Option "" ["tab-stop"]
171 , Option "" ["tab-stop"]
174 (ReqArg
172 (ReqArg
175 (\arg opt -> return opt { optTabStop = (read arg) } )
173 (\arg opt -> return opt { optTabStop = (read arg) } )
176 "TABSTOP")
174 "TABSTOP")
177− "Tab stop (default 4)"
175+ "" -- "Tab stop (default 4)"
178
176
179 , Option "" ["strict"]
177 , Option "" ["strict"]
180 (NoArg
178 (NoArg
181 (\opt -> return opt { optStrict = True } ))
179 (\opt -> return opt { optStrict = True } ))
182− "Use strict markdown syntax with no extensions"
180+ "" -- "Use strict markdown syntax with no extensions"
183
181
184 , Option "R" ["parse-raw"]
182 , Option "R" ["parse-raw"]
185 (NoArg
183 (NoArg
186 (\opt -> return opt { optParseRaw = True }))
184 (\opt -> return opt { optParseRaw = True }))
187− "Parse untranslatable HTML codes and LaTeX environments as raw"
185+ "" -- "Parse untranslatable HTML codes and LaTeX environments as raw"
188
186
189 , Option "S" ["smart"]
187 , Option "S" ["smart"]
190 (NoArg
188 (NoArg
191 (\opt -> return opt { optSmart = True }))
189 (\opt -> return opt { optSmart = True }))
192− "Use smart quotes, dashes, and ellipses in HTML output"
190+ "" -- "Use smart quotes, dashes, and ellipses in HTML output"
193
191
194 , Option "m" ["asciimathml"]
192 , Option "m" ["asciimathml"]
195 (NoArg
193 (NoArg
196 (\opt -> return opt { optASCIIMathML = True,
194 (\opt -> return opt { optASCIIMathML = True,
197 optStandalone = True }))
195 optStandalone = True }))
198− "Use ASCIIMathML script in html output"
196+ "" -- "Use ASCIIMathML script in html output"
199
197
200 , Option "i" ["incremental"]
198 , Option "i" ["incremental"]
201 (NoArg
199 (NoArg
202 (\opt -> return opt { optIncremental = True }))
200 (\opt -> return opt { optIncremental = True }))
203− "Make list items display incrementally in S5"
201+ "" -- "Make list items display incrementally in S5"
204
202
205 , Option "N" ["number-sections"]
203 , Option "N" ["number-sections"]
206 (NoArg
204 (NoArg
207 (\opt -> return opt { optNumberSections = True }))
205 (\opt -> return opt { optNumberSections = True }))
208− "Number sections in LaTeX"
206+ "" -- "Number sections in LaTeX"
209
207
210 , Option "c" ["css"]
208 , Option "c" ["css"]
211 (ReqArg
209 (ReqArg
212 (\arg opt -> return opt { optCSS = arg,
210 (\arg opt -> return opt { optCSS = arg,
213 optStandalone = True })
211 optStandalone = True })
214 "CSS")
212 "CSS")
215− "Link to CSS style sheet"
213+ "" -- "Link to CSS style sheet"
216
214
217 , Option "H" ["include-in-header"]
215 , Option "H" ["include-in-header"]
218 (ReqArg
216 (ReqArg
@@ -221,7 +219,7 @@ options =
221 return opt { optIncludeInHeader = text,
219 return opt { optIncludeInHeader = text,
222 optStandalone = True })
220 optStandalone = True })
223 "FILENAME")
221 "FILENAME")
224− "File to include at end of header (implies -s)"
222+ "" -- "File to include at end of header (implies -s)"
225
223
226 , Option "B" ["include-before-body"]
224 , Option "B" ["include-before-body"]
227 (ReqArg
225 (ReqArg
@@ -229,7 +227,7 @@ options =
229 text <- readFile arg
227 text <- readFile arg
230 return opt { optIncludeBeforeBody = text })
228 return opt { optIncludeBeforeBody = text })
231 "FILENAME")
229 "FILENAME")
232− "File to include before document body"
230+ "" -- "File to include before document body"
233
231
234 , Option "A" ["include-after-body"]
232 , Option "A" ["include-after-body"]
235 (ReqArg
233 (ReqArg
@@ -237,7 +235,7 @@ options =
237 text <- readFile arg
235 text <- readFile arg
238 return opt { optIncludeAfterBody = text })
236 return opt { optIncludeAfterBody = text })
239 "FILENAME")
237 "FILENAME")
240− "File to include after document body"
238+ "" -- "File to include after document body"
241
239
242 , Option "C" ["custom-header"]
240 , Option "C" ["custom-header"]
243 (ReqArg
241 (ReqArg
@@ -246,14 +244,14 @@ options =
246 return opt { optCustomHeader = text,
244 return opt { optCustomHeader = text,
247 optStandalone = True })
245 optStandalone = True })
248 "FILENAME")
246 "FILENAME")
249− "File to use for custom header (implies -s)"
247+ "" -- "File to use for custom header (implies -s)"
250
248
251 , Option "T" ["title-prefix"]
249 , Option "T" ["title-prefix"]
252 (ReqArg
250 (ReqArg
253 (\arg opt -> return opt { optTitlePrefix = arg,
251 (\arg opt -> return opt { optTitlePrefix = arg,
254 optStandalone = True })
252 optStandalone = True })
255 "STRING")
253 "STRING")
256− "String to prefix to HTML window title"
254+ "" -- "String to prefix to HTML window title"
257
255
258 , Option "D" ["print-default-header"]
256 , Option "D" ["print-default-header"]
259 (ReqArg
257 (ReqArg
@@ -264,12 +262,12 @@ options =
264 hPutStr stdout header
262 hPutStr stdout header
265 exitWith ExitSuccess)
263 exitWith ExitSuccess)
266 "FORMAT")
264 "FORMAT")
267− "Print default header for FORMAT"
265+ "" -- "Print default header for FORMAT"
268
266
269 , Option "d" ["debug"]
267 , Option "d" ["debug"]
270 (NoArg
268 (NoArg
271 (\opt -> return opt { optDebug = True }))
269 (\opt -> return opt { optDebug = True }))
272− "Print debug messages to stderr, output to stdout"
270+ "" -- "Print debug messages to stderr, output to stdout"
273
271
274 , Option "v" ["version"]
272 , Option "v" ["version"]
275 (NoArg
273 (NoArg
@@ -278,24 +276,25 @@ options =
278 hPutStrLn stderr (prg ++ " " ++ version ++
276 hPutStrLn stderr (prg ++ " " ++ version ++
279 copyrightMessage)
277 copyrightMessage)
280 exitWith $ ExitFailure 2))
278 exitWith $ ExitFailure 2))
281− "Print version"
279+ "" -- "Print version"
282
280
283 , Option "h" ["help"]
281 , Option "h" ["help"]
284 (NoArg
282 (NoArg
285 (\_ -> do
283 (\_ -> do
286 prg <- getProgName
284 prg <- getProgName
287− hPutStr stderr (reformatUsageInfo $
285+ hPutStr stderr (usageMessage prg options)
288− usageInfo (prg ++ " [OPTIONS] [FILES]") options)
289 exitWith $ ExitFailure 2))
286 exitWith $ ExitFailure 2))
290− "Show help"
287+ "" -- "Show help"
291 ]
288 ]
292
289
293−-- Reformat usage message so it doesn't wrap illegibly
290+-- Returns usage message
294−reformatUsageInfo :: String -> String
291+usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String
295−reformatUsageInfo = gsub " *--" " --" .
292+usageMessage programName options = usageInfo
296− gsub "(-[A-Za-z0-9]) *--" "\\1, --" .
293+ (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++
297− gsub " *([^- ])" "\n\t\\1"
294+ joinWithSep ", " (map fst readers) ++ "\nOutput formats: " ++
298−
295+ joinWithSep ", " (map fst writers) ++ "\nOptions:")
296+ options
297+
299-- Determine default reader based on source file extensions
298-- Determine default reader based on source file extensions
300defaultReaderName :: [String] -> String
299defaultReaderName :: [String] -> String
301defaultReaderName [] = "markdown"
300defaultReaderName [] = "markdown"
@@ -343,8 +342,7 @@ main = do
343 then do
342 then do
344 name <- getProgName
343 name <- getProgName
345 mapM (\e -> hPutStrLn stderr e) errors
344 mapM (\e -> hPutStrLn stderr e) errors
346− hPutStrLn stderr (reformatUsageInfo $
345+ hPutStr stderr (usageMessage name options)
347− usageInfo (name ++ " [OPTIONS] [FILES]") options)
348 exitWith $ ExitFailure 2
346 exitWith $ ExitFailure 2
349 else
347 else
350 return ()
348 return ()