|
20 | 20 | import static org.junit.Assert.assertEquals; |
21 | 21 | import static org.junit.Assert.assertTrue; |
22 | 22 |
|
| 23 | +import java.io.PrintWriter; |
| 24 | +import java.io.StringWriter; |
| 25 | + |
23 | 26 | import org.junit.Test; |
24 | 27 |
|
25 | 28 | /** |
@@ -220,8 +223,50 @@ public void testMan() |
220 | 223 | addOption("h", "help", false, "show this usage message."); |
221 | 224 |
|
222 | 225 | HelpFormatter hf = new HelpFormatter(); |
223 | | - //hf.printHelp(cmdLine, opts); |
224 | | - hf.printHelp(60, cmdLine, null, options, null); |
| 226 | + final String EOL = System.getProperty("line.separator"); |
| 227 | + StringWriter out = new StringWriter(); |
| 228 | + hf.printHelp(new PrintWriter(out), 60, cmdLine, null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false); |
| 229 | + assertEquals("usage: man [-c|-f|-k|-w|-tZT device] [-adlhu7V] [-Mpath]" + EOL + |
| 230 | + " [-Ppager] [-Slist] [-msystem] [-pstring]" + EOL + |
| 231 | + " [-Llocale] [-eextension] [section] page ..." + EOL + |
| 232 | + " -7,--ascii display ASCII translation or" + EOL + |
| 233 | + " certain latin1 chars." + EOL + |
| 234 | + " -a,--all find all matching manual pages." + EOL + |
| 235 | + " -c,--catman used by catman to reformat out of" + EOL + |
| 236 | + " date cat pages." + EOL + |
| 237 | + " -d,--debug emit debugging messages." + EOL + |
| 238 | + " -D,--default reset all options to their" + EOL + |
| 239 | + " default values." + EOL + |
| 240 | + " -e,--extension limit search to extension type" + EOL + |
| 241 | + " 'extension'." + EOL + |
| 242 | + " -f,--whatis equivalent to whatis." + EOL + |
| 243 | + " -h,--help show this usage message." + EOL + |
| 244 | + " -k,--apropos equivalent to apropos." + EOL + |
| 245 | + " -l,--local-file interpret 'page' argument(s) as" + EOL + |
| 246 | + " local filename(s)" + EOL + |
| 247 | + " -L,--locale <arg> define the locale for this" + EOL + |
| 248 | + " particular man search." + EOL + |
| 249 | + " -M,--manpath <arg> set search path for manual pages" + EOL + |
| 250 | + " to 'path'." + EOL + |
| 251 | + " -m,--systems <arg> search for man pages from other" + EOL + |
| 252 | + " unix system(s)." + EOL + |
| 253 | + " -P,--pager <arg> use program 'pager' to display" + EOL + |
| 254 | + " output." + EOL + |
| 255 | + " -p,--preprocessor <arg> string indicates which" + EOL + |
| 256 | + " preprocessor to run." + EOL + |
| 257 | + " e - [n]eqn p - pic t - tbl" + EOL + |
| 258 | + " g - grap r - refer v -" + EOL + |
| 259 | + " vgrind" + EOL + |
| 260 | + " -r,--prompt <arg> provide 'less' pager with prompt." + EOL + |
| 261 | + " -S,--sections <arg> use colon separated section list." + EOL + |
| 262 | + " -t,--troff use troff format pages." + EOL + |
| 263 | + " -T,--troff-device <arg> use groff with selected device." + EOL + |
| 264 | + " -u,--update force a cache consistency check." + EOL + |
| 265 | + " -V,--version show version." + EOL + |
| 266 | + " -w,--location print physical location of man" + EOL + |
| 267 | + " page(s)." + EOL + |
| 268 | + " -Z,--ditroff use groff with selected device." + EOL, |
| 269 | + out.toString()); |
225 | 270 | } |
226 | 271 |
|
227 | 272 |
|
|
0 commit comments