setup_board: argument deprecations

Add handling to print deprecation warnings when the old form
of the setup board arguments are used.

BUG=chromium:893748
TEST=manually verified warning printed
CQ-DEPEND=CL:1409763, CL:1407426, CL:1407709
CQ-DEPEND=CL:1409474, CL:1407532, CL:1407424
CQ-DEPEND=CL:1407460

Change-Id: I62b7ba61884d84072d3191df29baddbedc148181
Reviewed-on: https://chromium-review.googlesource.com/1432012
Commit-Ready: Alex Klein <saklein@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/setup_board.py b/scripts/setup_board.py
index 9eb595f..a5feee9 100644
--- a/scripts/setup_board.py
+++ b/scripts/setup_board.py
@@ -19,8 +19,9 @@
 
 def GetParser():
   """Build the argument parser."""
-  # TODO(saklein) Remove underscore separated arguments after 2019-06-01
-  # (crbug.com/922144).
+  # TODO(crbug.com/922144) Remove underscore separated arguments and the
+  # deprecated message after 2019-06-01.
+  deprecated = 'Argument will be removed 2019-06-01. Use %s instead.'
   parser = commandline.ArgumentParser(description=__doc__)
 
   parser.add_argument('--board', required=True,
@@ -37,8 +38,11 @@
                       dest='usepkg', help='Use binary packages to bootstrap.')
 
   advanced = parser.add_argument_group('Advanced Options')
-  advanced.add_argument('--accept-licenses', '--accept_licenses',
+  advanced.add_argument('--accept-licenses',
                         help='Licenses to append to the accept list.')
+  advanced.add_argument('--accept_licenses',
+                        deprecated=deprecated % '--accept-licenses',
+                        help='Deprecated form of --accept-licenses.')
 
   # Build target related arguments.
   target = parser.add_argument_group('Advanced Build Target Options')
@@ -46,35 +50,54 @@
                       help='The portage configuration profile to use. Profile '
                            'must be located in overlay-board/profiles.')
   target.add_argument('--variant', help='Board variant.')
-  target.add_argument('--board-root', '--board_root', type='path',
-                      help='Board root.')
+  target.add_argument('--board-root', type='path', help='Board root.')
+  target.add_argument('--board_root', type='path',
+                      deprecated=deprecated % '--board-root',
+                      help='Deprecated form of --board-root.')
 
   # Arguments related to the build itself.
   build = parser.add_argument_group('Advanced Build Modification Options')
   build.add_argument('--jobs', type=int,
                      help='Maximum number of packages to build in parallel.')
-  build.add_argument('--regen-configs', '--regen_configs', action='store_true',
-                     default=False,
+  build.add_argument('--regen-configs', action='store_true', default=False,
                      help='Regenerate all config files (useful for '
-                          'modifying profiles w/out rebuild).')
+                          'modifying profiles without rebuild).')
+  build.add_argument('--regen_configs', action='store_true', default=False,
+                     deprecated=deprecated % '--regen-configs',
+                     help='Deprecated form of --regen-configs.')
   build.add_argument('--quiet', action='store_true', default=False,
                      help="Don't print warnings when board already exists.")
-  build.add_argument('--skip-toolchain-update', '--skip_toolchain_update',
-                     action='store_true', default=False,
+  build.add_argument('--skip-toolchain-update', action='store_true',
+                     default=False,
                      help="Don't update toolchain automatically.")
-  build.add_argument('--skip-chroot-upgrade', '--skip_chroot_upgrade',
-                     action='store_true', default=False,
+  build.add_argument('--skip_toolchain_update', action='store_true',
+                     default=False,
+                     deprecated=deprecated % '--skip-toolchain-update',
+                     help='Deprecated form of --skip-toolchain-update.')
+  build.add_argument('--skip-chroot-upgrade', action='store_true',
+                     default=False,
                      help="Don't run the chroot upgrade automatically; "
                           'use with care.')
-  build.add_argument('--skip-board-pkg-init', '--skip_board_pkg_init',
-                     action='store_true', default=False,
+  build.add_argument('--skip_chroot_upgrade', action='store_true',
+                     default=False,
+                     deprecated=deprecated % '--skip-chroot-upgrade',
+                     help='Deprecated form of --skip-chroot-upgrade.')
+  build.add_argument('--skip-board-pkg-init', action='store_true',
+                     default=False,
                      help="Don't emerge any packages during setup_board into "
                           'the board root.')
-  build.add_argument('--reuse-pkgs-from-local-boards',
-                     '--reuse_pkgs_from_local_boards',
-                     dest='reuse_local', action='store_true', default=False,
+  build.add_argument('--skip_board_pkg_init', action='store_true',
+                     default=False,
+                     deprecated=deprecated % '--skip-board-pkg-init',
+                     help='Deprecated form of --skip-board-pkg-init.')
+  build.add_argument('--reuse-pkgs-from-local-boards', dest='reuse_local',
+                     action='store_true', default=False,
                      help='Bootstrap from local packages instead of remote '
                           'packages.')
+  build.add_argument('--reuse_pkgs_from_local_boards', dest='reuse_local',
+                     action='store_true', default=False,
+                     deprecated=deprecated % '--reuse-pkgs-from-local-boards',
+                     help='Deprecated form of --reuse-pkgs-from-local-boards.')
 
   return parser