From 6a2400a4d097b6e510dc9b8ec06283517b9ca3ad Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 16 Feb 2021 01:43:31 -0500 Subject: command: unify --job option & default values Extend the Command class to support adding the --jobs option to the parser if the command declares it supports running in parallel. Also pull the default value used for the number of local jobs into the command module so local commands can share it. Change-Id: I22b0f8d2cf69875013cec657b8e6c4385549ccac Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297024 Tested-by: Mike Frysinger Reviewed-by: Chris Mcdonald --- subcmds/forall.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'subcmds/forall.py') diff --git a/subcmds/forall.py b/subcmds/forall.py index ef11851b..d871b3ea 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -21,7 +21,7 @@ import sys import subprocess from color import Coloring -from command import Command, MirrorSafeCommand +from command import DEFAULT_LOCAL_JOBS, Command, MirrorSafeCommand import platform_utils _CAN_COLOR = [ @@ -113,8 +113,11 @@ terminal and are not redirected. If -e is used, when a command exits unsuccessfully, '%prog' will abort without iterating through the remaining projects. """ + PARALLEL_JOBS = DEFAULT_LOCAL_JOBS def _Options(self, p): + super()._Options(p) + def cmd(option, opt_str, value, parser): setattr(parser.values, option.dest, list(parser.rargs)) while parser.rargs: @@ -148,9 +151,6 @@ without iterating through the remaining projects. g.add_option('-v', '--verbose', dest='verbose', action='store_true', help='Show command error messages') - g.add_option('-j', '--jobs', - dest='jobs', action='store', type='int', default=1, - help='number of commands to execute simultaneously') def WantPager(self, opt): return opt.project_header and opt.jobs == 1 -- cgit v1.2.3-54-g00ecf