OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Tool to perform checkouts in one easy command line! | 7 Tool to perform checkouts in one easy command line! |
8 | 8 |
9 Usage: | 9 Usage: |
10 fetch <recipe> [--property=value [--property2=value2 ...]] | 10 fetch <recipe> [--property=value [--property2=value2 ...]] |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 """ | 149 """ |
150 usage: %s <recipe> [--property=value [--property2=value2 ...]] | 150 usage: %s <recipe> [--property=value [--property2=value2 ...]] |
151 """ % os.path.basename(sys.argv[0])) | 151 """ % os.path.basename(sys.argv[0])) |
152 sys.exit(bool(msg)) | 152 sys.exit(bool(msg)) |
153 | 153 |
154 | 154 |
155 def handle_args(argv): | 155 def handle_args(argv): |
156 """Gets the recipe name from the command line arguments.""" | 156 """Gets the recipe name from the command line arguments.""" |
157 if len(argv) <= 1: | 157 if len(argv) <= 1: |
158 usage('Must specify a recipe.') | 158 usage('Must specify a recipe.') |
| 159 if argv[1] in ('-h', '--help', 'help'): |
| 160 usage() |
159 | 161 |
160 def looks_like_arg(arg): | 162 def looks_like_arg(arg): |
161 return arg.startswith('--') and arg.count('=') == 1 | 163 return arg.startswith('--') and arg.count('=') == 1 |
162 | 164 |
163 bad_parms = [x for x in argv[2:] if not looks_like_arg(x)] | 165 bad_parms = [x for x in argv[2:] if not looks_like_arg(x)] |
164 if bad_parms: | 166 if bad_parms: |
165 usage('Got bad arguments %s' % bad_parms) | 167 usage('Got bad arguments %s' % bad_parms) |
166 | 168 |
167 recipe = argv[1] | 169 recipe = argv[1] |
168 props = argv[2:] | 170 props = argv[2:] |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 212 |
211 | 213 |
212 def main(): | 214 def main(): |
213 recipe, props = handle_args(sys.argv) | 215 recipe, props = handle_args(sys.argv) |
214 spec, root = run_recipe_fetch(recipe, props) | 216 spec, root = run_recipe_fetch(recipe, props) |
215 return run(spec, root) | 217 return run(spec, root) |
216 | 218 |
217 | 219 |
218 if __name__ == '__main__': | 220 if __name__ == '__main__': |
219 sys.exit(main()) | 221 sys.exit(main()) |
OLD | NEW |