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

Side by Side Diff: recipe_engine/refs.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/lint_test.py ('k') | recipe_engine/remote.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The LUCI Authors. All rights reserved. 1 # Copyright 2016 The LUCI Authors. All rights reserved.
2 # Use of this source code is governed under the Apache License, Version 2.0 2 # Use of this source code is governed under the Apache License, Version 2.0
3 # that can be found in the LICENSE file. 3 # that can be found in the LICENSE file.
4 4
5 from __future__ import print_function 5 from __future__ import print_function
6 6
7 from . import loader 7 from . import loader
8 8
9 9
10 def add_subparser(parser): 10 def add_subparser(parser):
11 helpstr = 'List places referencing given recipe module(s).' 11 helpstr = 'List places referencing given recipe module(s).'
12 refs_p = parser.add_parser( 12 refs_p = parser.add_parser(
13 'refs', help=helpstr, description=helpstr) 13 'refs', help=helpstr, description=helpstr)
14 refs_p.add_argument('modules', nargs='+', help='Module(s) to query for') 14 refs_p.add_argument('modules', nargs='+', help='Module(s) to query for')
15 refs_p.add_argument('--transitive', action='store_true', 15 refs_p.add_argument('--transitive', action='store_true',
16 help='Compute transitive closure of the references') 16 help='Compute transitive closure of the references')
17 17
18 refs_p.set_defaults(command='refs', func=main) 18 refs_p.set_defaults(func=main)
19 19
20 20
21 def main(package_deps, args): 21 def main(package_deps, args):
22 universe = loader.RecipeUniverse(package_deps, args.package) 22 universe = loader.RecipeUniverse(package_deps, args.package)
23 own_package = package_deps.root_package 23 own_package = package_deps.root_package
24 modules = args.modules 24 modules = args.modules
25 transitive = args.transitive 25 transitive = args.transitive
26 26
27 result_modules = set() 27 result_modules = set()
28 result_recipes = set() 28 result_recipes = set()
(...skipping 30 matching lines...) Expand all
59 59
60 if result_modules: 60 if result_modules:
61 print('Modules:') 61 print('Modules:')
62 for module in sorted(result_modules): 62 for module in sorted(result_modules):
63 print(' %s' % module) 63 print(' %s' % module)
64 64
65 if result_recipes: 65 if result_recipes:
66 print('Recipes:') 66 print('Recipes:')
67 for recipe in sorted(result_recipes): 67 for recipe in sorted(result_recipes):
68 print(' %s' % recipe) 68 print(' %s' % recipe)
OLDNEW
« no previous file with comments | « recipe_engine/lint_test.py ('k') | recipe_engine/remote.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698