OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import getopt | 5 import getopt |
6 import sys | 6 import sys |
7 | 7 |
8 from idl_log import ErrOut, InfoOut, WarnOut | 8 from idl_log import ErrOut, InfoOut, WarnOut |
9 | 9 |
10 OptionMap = { } | 10 OptionMap = { } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 else: | 53 else: |
54 out = ' -%-15.15s\t%s' % (option.name, option.desc) | 54 out = ' -%-15.15s\t%s' % (option.name, option.desc) |
55 if option.default: | 55 if option.default: |
56 out = '%s\n\t\t\t(Default: %s)\n' % (out, option.default) | 56 out = '%s\n\t\t\t(Default: %s)\n' % (out, option.default) |
57 InfoOut.Log(out) | 57 InfoOut.Log(out) |
58 | 58 |
59 def DumpHelp(option=None): | 59 def DumpHelp(option=None): |
60 InfoOut.Log('Usage:') | 60 InfoOut.Log('Usage:') |
61 for opt in sorted(OptionMap.keys()): | 61 for opt in sorted(OptionMap.keys()): |
62 DumpOption(OptionMap[opt]) | 62 DumpOption(OptionMap[opt]) |
63 | 63 sys.exit(0) |
64 | 64 |
65 # | 65 # |
66 # Default IDL options | 66 # Default IDL options |
67 # | 67 # |
68 # -h : Help, prints options | 68 # -h : Help, prints options |
69 # --verbose : use verbose output | 69 # --verbose : use verbose output |
70 # --test : test this module | 70 # --test : test this module |
71 # | 71 # |
72 Option('h', 'Help', callfunc=DumpHelp) | 72 Option('h', 'Help', callfunc=DumpHelp) |
| 73 Option('help', 'Help', callfunc=DumpHelp) |
73 Option('verbose', 'Verbose') | 74 Option('verbose', 'Verbose') |
74 Option('test', 'Test the IDL scripts') | 75 Option('test', 'Test the IDL scripts') |
75 | 76 |
76 def ParseOptions(args): | 77 def ParseOptions(args): |
77 short_opts= "" | 78 short_opts= "" |
78 long_opts = [] | 79 long_opts = [] |
79 | 80 |
80 # Build short and long option lists | 81 # Build short and long option lists |
81 for name in sorted(OptionMap.keys()): | 82 for name in sorted(OptionMap.keys()): |
82 option = OptionMap[name] | 83 option = OptionMap[name] |
(...skipping 15 matching lines...) Expand all Loading... |
98 if len(opt) == 2: opt = opt[1:] | 99 if len(opt) == 2: opt = opt[1:] |
99 if opt[0:2] == '--': opt = opt[2:] | 100 if opt[0:2] == '--': opt = opt[2:] |
100 OptionMap[opt].Set(val) | 101 OptionMap[opt].Set(val) |
101 | 102 |
102 except getopt.error, e: | 103 except getopt.error, e: |
103 ErrOut.Log('Illegal option: %s\n' % str(e)) | 104 ErrOut.Log('Illegal option: %s\n' % str(e)) |
104 DumpHelp() | 105 DumpHelp() |
105 sys.exit(-1) | 106 sys.exit(-1) |
106 | 107 |
107 return filenames | 108 return filenames |
OLD | NEW |