diff -r 7556dcd33177 pygments/cmdline.py
|
a
|
b
|
|
| 29 | 29 | |
| 30 | 30 | %s -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>] |
| 31 | 31 | %s -L [<which> ...] |
| | 32 | %s -N <infile> |
| 32 | 33 | %s -H <type> <name> |
| 33 | 34 | %s -h | -V |
| 34 | 35 | |
| … |
… |
|
| 67 | 68 | The -L option lists lexers, formatters, styles or filters -- set |
| 68 | 69 | `which` to the thing you want to list (e.g. "styles"), or omit it to |
| 69 | 70 | list everything. |
| | 71 | |
| | 72 | The -N option attempts to guess the appropriate lexer based solely on |
| | 73 | the filename. If no lexer can be determined "text" is returned. |
| 70 | 74 | |
| 71 | 75 | The -H option prints detailed help for the object <name> of type <type>, |
| 72 | 76 | where <type> is one of "lexer", "formatter" or "filter". |
| … |
… |
|
| 185 | 189 | """ |
| 186 | 190 | # pylint: disable-msg=R0911,R0912,R0915 |
| 187 | 191 | |
| 188 | | usage = USAGE % ((args[0],) * 5) |
| | 192 | usage = USAGE % ((args[0],) * 6) |
| 189 | 193 | |
| 190 | 194 | try: |
| 191 | | popts, args = getopt.getopt(args[1:], "l:f:F:o:O:P:LS:a:hVHg") |
| | 195 | popts, args = getopt.getopt(args[1:], "l:f:F:o:O:P:LS:a:N:hVHg") |
| 192 | 196 | except getopt.GetoptError, err: |
| 193 | 197 | print >>sys.stderr, usage |
| 194 | 198 | return 2 |
| … |
… |
|
| 260 | 264 | else: |
| 261 | 265 | parsed_opts[name] = value |
| 262 | 266 | opts.pop('-P', None) |
| | 267 | |
| | 268 | # handle ``pygmentize -N`` |
| | 269 | infn = opts.pop('-N', None) |
| | 270 | if infn is not None: |
| | 271 | try: |
| | 272 | lexer = get_lexer_for_filename(infn, **parsed_opts) |
| | 273 | except ClassNotFound, err: |
| | 274 | lexer = TextLexer() |
| | 275 | except OptionError, err: |
| | 276 | print >>sys.stderr, 'Error:', err |
| | 277 | return 1 |
| | 278 | |
| | 279 | print lexer.aliases[0] |
| | 280 | return 0 |
| 263 | 281 | |
| 264 | 282 | # handle ``pygmentize -S`` |
| 265 | 283 | S_opt = opts.pop('-S', None) |