Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: recipes.py

Issue 2845923002: [recipes.py] use argparse to set command automatically. (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « recipe_engine/test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2017 The LUCI Authors. All rights reserved. 2 # Copyright 2017 The LUCI Authors. All rights reserved.
3 # Use of this source code is governed under the Apache License, Version 2.0 3 # Use of this source code is governed under the Apache License, Version 2.0
4 # that can be found in the LICENSE file. 4 # that can be found in the LICENSE file.
5 5
6 """Tool to interact with recipe repositories. 6 """Tool to interact with recipe repositories.
7 7
8 This tool operates on the nearest ancestor directory containing an 8 This tool operates on the nearest ancestor directory containing an
9 infra/config/recipes.cfg. 9 infra/config/recipes.cfg.
10 """ 10 """
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 remote, 80 remote,
81 ] 81 ]
82 82
83 83
84 def main(): 84 def main():
85 parser = argparse.ArgumentParser( 85 parser = argparse.ArgumentParser(
86 description='Interact with the recipe system.') 86 description='Interact with the recipe system.')
87 87
88 common_postprocess_func = common_args.add_common_args(parser) 88 common_postprocess_func = common_args.add_common_args(parser)
89 89
90 subp = parser.add_subparsers() 90 subp = parser.add_subparsers(dest='command')
91 for module in _SUBCOMMANDS: 91 for module in _SUBCOMMANDS:
92 module.add_subparser(subp) 92 module.add_subparser(subp)
93 93
94 args = parser.parse_args() 94 args = parser.parse_args()
95 common_postprocess_func(parser, args) 95 common_postprocess_func(parser, args)
96 args.postprocess_func(parser, args) 96 args.postprocess_func(parser, args)
97 97
98 # If we're bootstrapping, construct our bootstrap environment. If we're 98 # If we're bootstrapping, construct our bootstrap environment. If we're
99 # using a custom deps path, install our enviornment there too. 99 # using a custom deps path, install our enviornment there too.
100 if args.use_bootstrap and not env.USING_BOOTSTRAP: 100 if args.use_bootstrap and not env.USING_BOOTSTRAP:
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 if not isinstance(ret, int): 164 if not isinstance(ret, int):
165 if ret is None: 165 if ret is None:
166 ret = 0 166 ret = 0
167 else: 167 else:
168 print >> sys.stderr, ret 168 print >> sys.stderr, ret
169 ret = 1 169 ret = 1
170 sys.stdout.flush() 170 sys.stdout.flush()
171 sys.stderr.flush() 171 sys.stderr.flush()
172 os._exit(ret) 172 os._exit(ret)
OLDNEW
« no previous file with comments | « recipe_engine/test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698