Skip to content

Commit

Permalink
[recipes.py] use argparse to set command automatically.
Browse files Browse the repository at this point in the history
R=dnj@chromium.org, phajdan.jr@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2845923002
  • Loading branch information
riannucci authored and Commit bot committed Apr 29, 2017
1 parent 6715579 commit 974abea
Show file tree
Hide file tree
Showing 11 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion recipe_engine/autoroll.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def postprocess_func(parser, args):
parser.error('--verbose-json passed without --output-json')

autoroll_p.set_defaults(
command='autoroll', func=main, postprocess_func=postprocess_func)
func=main, postprocess_func=postprocess_func)


def main(_package_deps, args):
Expand Down
2 changes: 1 addition & 1 deletion recipe_engine/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def add_subparser(parser):
type=os.path.abspath,
help='The directory of where to put the bundle (default: %(default)r).')

bundle_p.set_defaults(command='bundle', func=main)
bundle_p.set_defaults(func=main)


def main(package_deps, args):
Expand Down
2 changes: 1 addition & 1 deletion recipe_engine/depgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def add_subparser(parser):
'this substring. It will also filter all nodes of the graph to only '
'include modules touched by the filtered recipes.'))

depgraph_p.set_defaults(command='depgraph', func=main)
depgraph_p.set_defaults(func=main)


def main(package_deps, args):
Expand Down
2 changes: 1 addition & 1 deletion recipe_engine/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def add_subparser(parser):
doc_p.add_argument('--kind', default='jsonpb', choices=doc_kinds,
help='Output this kind of documentation')

doc_p.set_defaults(command='doc', func=main)
doc_p.set_defaults(func=main)


def main(package_deps, args):
Expand Down
1 change: 0 additions & 1 deletion recipe_engine/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def postprocess_func(parser, args):
parser.error('--no-fetch does not make sense with fetch command')

fetch_p.set_defaults(
command='fetch',
# fetch action is implied by recipes.py
func=(lambda package_deps, engine_flags: 0),
postprocess_func=postprocess_func,
Expand Down
2 changes: 1 addition & 1 deletion recipe_engine/lint_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def add_subparser(parser):
help='A regexp matching module names to add to the default whitelist. '
'Use multiple times to add multiple patterns,')

lint_p.set_defaults(command='lint', func=main)
lint_p.set_defaults(func=main)


def main(package_deps, args):
Expand Down
2 changes: 1 addition & 1 deletion recipe_engine/refs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def add_subparser(parser):
refs_p.add_argument('--transitive', action='store_true',
help='Compute transitive closure of the references')

refs_p.set_defaults(command='refs', func=main)
refs_p.set_defaults(func=main)


def main(package_deps, args):
Expand Down
1 change: 0 additions & 1 deletion recipe_engine/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def add_subparser(parser):
help='Arguments to pass to fetched repo\'s recipes.py')

remote_p.set_defaults(
command='remote',
bare_command=True,
func=main,
)
Expand Down
2 changes: 1 addition & 1 deletion recipe_engine/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ def properties_type(value):
'issue=12345. The property value will be decoded as JSON, but if '
'this decoding fails the value will be interpreted as a string.'))

run_p.set_defaults(command='run', properties={}, func=main)
run_p.set_defaults(properties={}, func=main)


def handle_recipe_return(recipe_result, result_filename, stream_engine,
Expand Down
3 changes: 1 addition & 2 deletions recipe_engine/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,7 @@ def postprocess_func(_parser, args):
args.use_bootstrap = True

test_p.set_defaults(
command='test', func=main,
postprocess_func=postprocess_func,
func=main, postprocess_func=postprocess_func,
)


Expand Down
2 changes: 1 addition & 1 deletion recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def main():

common_postprocess_func = common_args.add_common_args(parser)

subp = parser.add_subparsers()
subp = parser.add_subparsers(dest='command')
for module in _SUBCOMMANDS:
module.add_subparser(subp)

Expand Down

0 comments on commit 974abea

Please sign in to comment.