cbuildbot: Clean up add_option code.

This CL is just a clean up.
- Use default values for action, type, dest and default named
  args if possible.
- Reorder named args for consistency, based on the manual,
  https://docs.python.org/3.6/library/optparse.html#option-attributes
  except help= is put at last always.
- Remove unneeded paren for help's concat string.
  For formatting, paren is kept as is following lint.

BUG=None
TEST=Run cbuildbot --help, and still works.

Change-Id: Ia19c13eb9dffdacc5f20bd81d129c66c8395d065
Reviewed-on: https://chromium-review.googlesource.com/452104
Commit-Ready: Hidehiko Abe <hidehiko@chromium.org>
Tested-by: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cbuildbot.py b/scripts/cbuildbot.py
index 0887d1d..90cd55a 100644
--- a/scripts/cbuildbot.py
+++ b/scripts/cbuildbot.py
@@ -398,39 +398,38 @@
                     default=False,
                     help='List all of the buildbot configs available w/--list')
 
-  parser.add_option('--local', default=False, action='store_true',
-                    help=('Specifies that this tryjob should be run locally. '
-                          'Implies --debug.'))
-  parser.add_option('--remote', default=False, action='store_true',
+  parser.add_option('--local', action='store_true', default=False,
+                    help='Specifies that this tryjob should be run locally. '
+                         'Implies --debug.')
+  parser.add_option('--remote', action='store_true', default=False,
                     help='Specifies that this tryjob should be run remotely.')
 
   parser.add_remote_option('-b', '--branch',
-                           help=('The manifest branch to test.  The branch to '
-                                 'check the buildroot out to.'))
-  parser.add_option('-r', '--buildroot', dest='buildroot', type='path',
-                    help=('Root directory where source is checked out to, and '
-                          'where the build occurs. For external build configs, '
-                          "defaults to 'trybot' directory at top level of your "
-                          'repo-managed checkout.'))
-  parser.add_option('--bootstrap-dir', type='path', default=None,
+                           help='The manifest branch to test.  The branch to '
+                                'check the buildroot out to.')
+  parser.add_option('-r', '--buildroot', type='path', dest='buildroot',
+                    help='Root directory where source is checked out to, and '
+                         'where the build occurs. For external build configs, '
+                         "defaults to 'trybot' directory at top level of your "
+                         'repo-managed checkout.')
+  parser.add_option('--bootstrap-dir', type='path',
                     help='Bootstrapping cbuildbot may involve checking out '
                          'multiple copies of chromite. All these checkouts '
                          'will be contained in the directory specified here. '
                          'Default:%s' % osutils.GetGlobalTempDir())
-  parser.add_remote_option('--android_rev', default=None, type='choice',
+  parser.add_remote_option('--android_rev', type='choice',
                            choices=constants.VALID_ANDROID_REVISIONS,
                            help=('Revision of Android to use, of type [%s]'
                                  % '|'.join(constants.VALID_ANDROID_REVISIONS)))
-  parser.add_remote_option('--chrome_rev', default=None, type='choice',
+  parser.add_remote_option('--chrome_rev', type='choice',
                            choices=constants.VALID_CHROME_REVISIONS,
                            help=('Revision of Chrome to use, of type [%s]'
                                  % '|'.join(constants.VALID_CHROME_REVISIONS)))
-  parser.add_remote_option('--profile', default=None, type='string',
-                           action='store', dest='profile',
+  parser.add_remote_option('--profile',
                            help='Name of profile to sub-specify board variant.')
   parser.add_option('-c', '--config_repo',
-                    help=('Cloneable path to the git repository containing '
-                          'the site configuration to use.'))
+                    help='Cloneable path to the git repository containing '
+                         'the site configuration to use.')
 
   #
   # Patch selection options.
@@ -441,23 +440,23 @@
       'Patch Options')
 
   group.add_remote_option('-g', '--gerrit-patches', action='extend',
-                          default=[], type='string',
+                          type='string', default=[],
                           metavar="'Id1 *int_Id2...IdN'",
-                          help=('Space-separated list of short-form Gerrit '
-                                "Change-Id's or change numbers to patch. "
-                                "Please prepend '*' to internal Change-Id's"))
+                          help='Space-separated list of short-form Gerrit '
+                               "Change-Id's or change numbers to patch. "
+                               "Please prepend '*' to internal Change-Id's")
   group.add_remote_option('-G', '--rietveld-patches', action='extend',
-                          default=[], type='string',
+                          type='string', default=[],
                           metavar="'id1[:subdir1]...idN[:subdirN]'",
-                          help=('Space-separated list of short-form Rietveld '
-                                'issue numbers to patch. If no subdir is '
-                                'specified, the src directory is used.'))
+                          help='Space-separated list of short-form Rietveld '
+                               'issue numbers to patch. If no subdir is '
+                               'specified, the src directory is used.')
   group.add_option('-p', '--local-patches', action='extend', default=[],
                    metavar="'<project1>[:<branch1>]...<projectN>[:<branchN>]'",
-                   help=('Space-separated list of project branches with '
-                         'patches to apply.  Projects are specified by name. '
-                         'If no branch is specified the current branch of the '
-                         'project will be used.'))
+                   help='Space-separated list of project branches with '
+                        'patches to apply.  Projects are specified by name. '
+                        'If no branch is specified the current branch of the '
+                        'project will be used.')
 
   parser.add_option_group(group)
 
@@ -469,29 +468,27 @@
       parser,
       'Remote Trybot Options (--remote)')
 
-  group.add_option('--use-buildbucket', default=False, action='store_true',
-                   help=('Use buildbucket instead of git to request'
-                         'the tryjob(s).'))
+  group.add_option('--use-buildbucket', action='store_true', default=False,
+                   help='Use buildbucket instead of git to request'
+                        'the tryjob(s).')
 
-  group.add_remote_option('--hwtest', dest='hwtest', action='store_true',
-                          default=False,
+  group.add_remote_option('--hwtest', action='store_true', default=False,
                           help='Run the HWTest stage (tests on real hardware)')
-  group.add_option('--remote-description', default=None,
-                   help=('Attach an optional description to a --remote run '
-                         'to make it easier to identify the results when it '
-                         'finishes'))
+  group.add_option('--remote-description',
+                   help='Attach an optional description to a --remote run '
+                        'to make it easier to identify the results when it '
+                        'finishes')
   group.add_option('--slaves', action='extend', default=[],
-                   help=('Specify specific remote tryslaves to run on (e.g. '
-                         'build149-m2); if the bot is busy, it will be queued'))
-  group.add_remote_option('--channel', dest='channels', action='extend',
+                   help='Specify specific remote tryslaves to run on (e.g. '
+                        'build149-m2); if the bot is busy, it will be queued')
+  group.add_remote_option('--channel', action='extend', dest='channels',
                           default=[],
-                          help=('Specify a channel for a payloads trybot. Can '
-                                'be specified multiple times. No valid for '
-                                'non-payloads configs.'))
-  group.add_option('--test-tryjob', action='store_true',
-                   default=False,
-                   help=('Submit a tryjob to the test repository.  Will not '
-                         'show up on the production trybot waterfall.'))
+                          help='Specify a channel for a payloads trybot. Can '
+                               'be specified multiple times. No valid for '
+                               'non-payloads configs.')
+  group.add_option('--test-tryjob', action='store_true', default=False,
+                   help='Submit a tryjob to the test repository.  Will not '
+                        'show up on the production trybot waterfall.')
 
   parser.add_option_group(group)
 
@@ -505,14 +502,14 @@
 
   group.add_remote_option('--branch-name',
                           help='The branch to create or delete.')
-  group.add_remote_option('--delete-branch', default=False, action='store_true',
+  group.add_remote_option('--delete-branch', action='store_true', default=False,
                           help='Delete the branch specified in --branch-name.')
-  group.add_remote_option('--rename-to', type='string',
+  group.add_remote_option('--rename-to',
                           help='Rename a branch to the specified name.')
-  group.add_remote_option('--force-create', default=False, action='store_true',
+  group.add_remote_option('--force-create', action='store_true', default=False,
                           help='Overwrites an existing branch.')
-  group.add_remote_option('--skip-remote-push', default=False,
-                          action='store_true',
+  group.add_remote_option('--skip-remote-push', action='store_true',
+                          default=False,
                           help='Do not actually push to remote git repos.  '
                                'Used for end-to-end testing branching.')
 
@@ -528,9 +525,9 @@
       'Caution: use these options at your own risk.')
 
   group.add_remote_option('--bootstrap-args', action='append', default=[],
-                          help=('Args passed directly to the bootstrap re-exec '
-                                'to skip verification by the bootstrap code'))
-  group.add_remote_option('--buildbot', dest='buildbot', action='store_true',
+                          help='Args passed directly to the bootstrap re-exec '
+                               'to skip verification by the bootstrap code')
+  group.add_remote_option('--buildbot', action='store_true', dest='buildbot',
                           default=False,
                           help='This is running on a buildbot. '
                                'This can be used to make a build operate '
@@ -549,38 +546,37 @@
                           help='Suppress buildbot specific tags from log '
                                'output. This is used to hide recursive '
                                'cbuilbot runs on the waterfall.')
-  group.add_remote_option('--buildnumber', help='build number', type='int',
-                          default=0)
-  group.add_option('--chrome_root', default=None, type='path',
-                   action='callback', callback=_CheckChromeRootOption,
-                   dest='chrome_root', help='Local checkout of Chrome to use.')
-  group.add_remote_option('--chrome_version', default=None, type='string',
-                          action='callback', dest='chrome_version',
+  group.add_remote_option('--buildnumber', type='int', default=0,
+                          help='build number')
+  group.add_option('--chrome_root', action='callback', type='path',
+                   callback=_CheckChromeRootOption,
+                   help='Local checkout of Chrome to use.')
+  group.add_remote_option('--chrome_version', action='callback', type='string',
+                          dest='chrome_version',
                           callback=_CheckChromeVersionOption,
-                          help=('Used with SPEC logic to force a particular '
-                                'git revision of chrome rather than the '
-                                'latest.'))
-  group.add_remote_option('--clobber', action='store_true', dest='clobber',
-                          default=False,
+                          help='Used with SPEC logic to force a particular '
+                               'git revision of chrome rather than the '
+                               'latest.')
+  group.add_remote_option('--clobber', action='store_true', default=False,
                           help='Clears an old checkout before syncing')
   group.add_remote_option('--latest-toolchain', action='store_true',
                           default=False,
                           help='Use the latest toolchain.')
   parser.add_option('--log_dir', dest='log_dir', type='path',
-                    help=('Directory where logs are stored.'))
-  group.add_remote_option('--maxarchives', dest='max_archive_builds',
-                          default=3, type='int',
+                    help='Directory where logs are stored.')
+  group.add_remote_option('--maxarchives', type='int',
+                          dest='max_archive_builds', default=3,
                           help='Change the local saved build count limit.')
   parser.add_remote_option('--manifest-repo-url',
-                           help=('Overrides the default manifest repo url.'))
+                           help='Overrides the default manifest repo url.')
   group.add_remote_option('--compilecheck', action='store_true', default=False,
                           help='Only verify compilation and unit tests.')
   group.add_remote_option('--noarchive', action='store_false', dest='archive',
                           default=True, help="Don't run archive stage.")
   group.add_remote_option('--nobootstrap', action='store_false',
                           dest='bootstrap', default=True,
-                          help=("Don't checkout and run from a standalone "
-                                'chromite repo.'))
+                          help="Don't checkout and run from a standalone "
+                               'chromite repo.')
   group.add_remote_option('--nobuild', action='store_false', dest='build',
                           default=True,
                           help="Don't actually build (for cbuildbot dev)")
@@ -591,65 +587,63 @@
                           help='Disable cbuildbots usage of cgroups.')
   group.add_remote_option('--nochromesdk', action='store_false',
                           dest='chrome_sdk', default=True,
-                          help=("Don't run the ChromeSDK stage which builds "
-                                'Chrome outside of the chroot.'))
+                          help="Don't run the ChromeSDK stage which builds "
+                               'Chrome outside of the chroot.')
   group.add_remote_option('--noprebuilts', action='store_false',
                           dest='prebuilts', default=True,
                           help="Don't upload prebuilts.")
   group.add_remote_option('--nopatch', action='store_false',
                           dest='postsync_patch', default=True,
-                          help=("Don't run PatchChanges stage.  This does not "
-                                'disable patching in of chromite patches '
-                                'during BootstrapStage.'))
+                          help="Don't run PatchChanges stage.  This does not "
+                               'disable patching in of chromite patches '
+                               'during BootstrapStage.')
   group.add_remote_option('--nopaygen', action='store_false',
                           dest='paygen', default=True,
                           help="Don't generate payloads.")
   group.add_remote_option('--noreexec', action='store_false',
                           dest='postsync_reexec', default=True,
                           help="Don't reexec into the buildroot after syncing.")
-  group.add_remote_option('--nosdk', action='store_true',
-                          default=False,
+  group.add_remote_option('--nosdk', action='store_true', default=False,
                           help='Re-create the SDK from scratch.')
   group.add_remote_option('--nosync', action='store_false', dest='sync',
                           default=True, help="Don't sync before building.")
   group.add_remote_option('--notests', action='store_false', dest='tests',
                           default=True,
-                          help=('Override values from buildconfig and run no '
-                                'tests.'))
+                          help='Override values from buildconfig and run no '
+                               'tests.')
   group.add_remote_option('--noimagetests', action='store_false',
                           dest='image_test', default=True,
-                          help=('Override values from buildconfig and run no '
-                                'image tests.'))
+                          help='Override values from buildconfig and run no '
+                               'image tests.')
   group.add_remote_option('--nouprev', action='store_false', dest='uprev',
                           default=True,
-                          help=('Override values from buildconfig and never '
-                                'uprev.'))
-  group.add_option('--reference-repo', action='store', default=None,
-                   dest='reference_repo',
-                   help=('Reuse git data stored in an existing repo '
-                         'checkout. This can drastically reduce the network '
-                         'time spent setting up the trybot checkout.  By '
-                         "default, if this option isn't given but cbuildbot "
-                         'is invoked from a repo checkout, cbuildbot will '
-                         'use the repo root.'))
+                          help='Override values from buildconfig and never '
+                               'uprev.')
+  group.add_option('--reference-repo',
+                   help='Reuse git data stored in an existing repo '
+                        'checkout. This can drastically reduce the network '
+                        'time spent setting up the trybot checkout.  By '
+                        "default, if this option isn't given but cbuildbot "
+                        'is invoked from a repo checkout, cbuildbot will '
+                        'use the repo root.')
   group.add_option('--resume', action='store_true', default=False,
                    help='Skip stages already successfully completed.')
-  group.add_remote_option('--timeout', action='store', type='int', default=0,
-                          help=('Specify the maximum amount of time this job '
-                                'can run for, at which point the build will be '
-                                'aborted.  If set to zero, then there is no '
-                                'timeout.'))
-  group.add_remote_option('--version', dest='force_version', default=None,
-                          help=('Used with manifest logic.  Forces use of this '
-                                'version rather than create or get latest. '
-                                'Examples: 4815.0.0-rc1, 4815.1.2'))
-  group.add_remote_option('--git-cache-dir', dest='git_cache_dir', default=None,
+  group.add_remote_option('--timeout', type='int', default=0,
+                          help='Specify the maximum amount of time this job '
+                               'can run for, at which point the build will be '
+                               'aborted.  If set to zero, then there is no '
+                               'timeout.')
+  group.add_remote_option('--version', dest='force_version',
+                          help='Used with manifest logic.  Forces use of this '
+                               'version rather than create or get latest. '
+                               'Examples: 4815.0.0-rc1, 4815.1.2')
+  group.add_remote_option('--git-cache-dir', type='path',
                           api=constants.REEXEC_API_GIT_CACHE_DIR,
-                          help=('Specify the cache directory to store the '
-                                'project caches populated by the git-cache '
-                                'tool. Bootstrap the projects based on the git '
-                                'cache files instead of fetching them directly '
-                                'from the GoB servers.'))
+                          help='Specify the cache directory to store the '
+                               'project caches populated by the git-cache '
+                               'tool. Bootstrap the projects based on the git '
+                               'cache files instead of fetching them directly '
+                               'from the GoB servers.')
 
   parser.add_option_group(group)
 
@@ -663,65 +657,63 @@
       'Caution: these are for meant for the Chromium OS build team only')
 
   group.add_remote_option('--archive-base', type='gs_path',
-                          help=('Base GS URL (gs://<bucket_name>/<path>) to '
-                                'upload archive artifacts to'))
+                          help='Base GS URL (gs://<bucket_name>/<path>) to '
+                               'upload archive artifacts to')
   group.add_remote_option(
-      '--cq-gerrit-query', dest='cq_gerrit_override', default=None,
-      help=('If given, this gerrit query will be used to find what patches to '
-            "test, rather than the normal 'CommitQueue>=1 AND Verified=1 AND "
-            "CodeReview=2' query it defaults to.  Use with care- note "
-            'additionally this setting only has an effect if the buildbot '
-            "target is a cq target, and we're in buildbot mode."))
-  group.add_option('--pass-through', dest='pass_through_args', action='append',
-                   type='string', default=[])
-  group.add_option('--reexec-api-version', dest='output_api_version',
-                   action='store_true', default=False,
-                   help=('Used for handling forwards/backwards compatibility '
-                         'with --resume and --bootstrap'))
-  group.add_option('--remote-trybot', dest='remote_trybot',
-                   action='store_true', default=False,
+      '--cq-gerrit-query', dest='cq_gerrit_override',
+      help='If given, this gerrit query will be used to find what patches to '
+           "test, rather than the normal 'CommitQueue>=1 AND Verified=1 AND "
+           "CodeReview=2' query it defaults to.  Use with care- note "
+           'additionally this setting only has an effect if the buildbot '
+           "target is a cq target, and we're in buildbot mode.")
+  group.add_option('--pass-through', action='append', type='string',
+                   dest='pass_through_args', default=[])
+  group.add_option('--reexec-api-version', action='store_true',
+                   dest='output_api_version', default=False,
+                   help='Used for handling forwards/backwards compatibility '
+                        'with --resume and --bootstrap')
+  group.add_option('--remote-trybot', action='store_true', default=False,
                    help='Indicates this is running on a remote trybot machine')
-  group.add_option('--buildbucket-id', dest='buildbucket_id', default=None,
-                   help=('The unique ID in buildbucket of current build '
-                         'generated by buildbucket.'))
+  group.add_option('--buildbucket-id',
+                   help='The unique ID in buildbucket of current build '
+                        'generated by buildbucket.')
   group.add_remote_option('--remote-patches', action='extend', default=[],
-                          help=('Patches uploaded by the trybot client when '
-                                'run using the -p option'))
+                          help='Patches uploaded by the trybot client when '
+                               'run using the -p option')
   # Note the default here needs to be hardcoded to 3; that is the last version
   # that lacked this functionality.
-  group.add_option('--remote-version', default=3, type=int, action='store',
-                   help=('Used for compatibility checks w/tryjobs running in '
-                         'older chromite instances'))
+  group.add_option('--remote-version', type='int', default=3,
+                   help='Used for compatibility checks w/tryjobs running in '
+                        'older chromite instances')
   group.add_option('--sourceroot', type='path', default=constants.SOURCE_ROOT)
   group.add_remote_option('--test-bootstrap', action='store_true',
                           default=False,
-                          help=('Causes cbuildbot to bootstrap itself twice, '
-                                'in the sequence A->B->C: A(unpatched) patches '
-                                'and bootstraps B; B patches and bootstraps C'))
-  group.add_remote_option('--validation_pool', default=None,
-                          help=('Path to a pickled validation pool. Intended '
-                                'for use only with the commit queue.'))
-  group.add_remote_option('--metadata_dump', default=None,
-                          help=('Path to a json dumped metadata file. This '
-                                'will be used as the initial metadata.'))
-  group.add_remote_option('--master-build-id', default=None, type=int,
+                          help='Causes cbuildbot to bootstrap itself twice, '
+                               'in the sequence A->B->C: A(unpatched) patches '
+                               'and bootstraps B; B patches and bootstraps C')
+  group.add_remote_option('--validation_pool',
+                          help='Path to a pickled validation pool. Intended '
+                               'for use only with the commit queue.')
+  group.add_remote_option('--metadata_dump',
+                          help='Path to a json dumped metadata file. This '
+                               'will be used as the initial metadata.')
+  group.add_remote_option('--master-build-id', type='int',
                           api=constants.REEXEC_API_MASTER_BUILD_ID,
-                          help=('cidb build id of the master build to this '
-                                'slave build.'))
-  group.add_remote_option('--mock-tree-status', dest='mock_tree_status',
-                          default=None, action='store',
-                          help=('Override the tree status value that would be '
-                                'returned from the the actual tree. Example '
-                                'values: open, closed, throttled. When used '
-                                'in conjunction with --debug, the tree status '
-                                'will not be ignored as it usually is in a '
-                                '--debug run.'))
-  group.add_remote_option(
-      '--mock-slave-status', dest='mock_slave_status', default=None,
-      action='store', metavar='MOCK_SLAVE_STATUS_PICKLE_FILE',
-      help=('Override the result of the _FetchSlaveStatuses method of '
-            'MasterSlaveSyncCompletionStage, by specifying a file with a '
-            'pickle of the result to be returned.'))
+                          help='cidb build id of the master build to this '
+                               'slave build.')
+  group.add_remote_option('--mock-tree-status',
+                          help='Override the tree status value that would be '
+                               'returned from the the actual tree. Example '
+                               'values: open, closed, throttled. When used '
+                               'in conjunction with --debug, the tree status '
+                               'will not be ignored as it usually is in a '
+                               '--debug run.')
+  group.add_remote_option('--mock-slave-status',
+                          metavar='MOCK_SLAVE_STATUS_PICKLE_FILE',
+                          help='Override the result of the _FetchSlaveStatuses '
+                               'method of MasterSlaveSyncCompletionStage, by '
+                               'specifying a file with a pickle of the result '
+                               'to be returned.')
 
   parser.add_option_group(group)
 
@@ -735,8 +727,8 @@
   debug.help += '  Currently functions as --dry-run in addition.'
   debug.pass_through = True
   group.add_option('--notee', action='store_false', dest='tee', default=True,
-                   help=('Disable logging and internal tee process.  Primarily '
-                         'used for debugging cbuildbot itself.'))
+                   help='Disable logging and internal tee process.  Primarily '
+                        'used for debugging cbuildbot itself.')
   return parser