def parse_args(args=None, *, parser_type=None):
  parser_type = parser_type or argparse.ArgumentParser
  parser = parser_type(
      description='Update the active milestones for the chromium project')
  parser.set_defaults(func=None)
  parser.add_argument('--milestones-json',
                      help='Path to the milestones.json file',
                      default=os.path.join(INFRA_CONFIG_DIR, 'milestones.json'))

  subparsers = parser.add_subparsers()

  activate_parser = subparsers.add_parser(
      'activate', help='Add an additional active milestone')
  activate_parser.set_defaults(func=activate_cmd)
  activate_parser.add_argument(
      '--milestone',
      required=True,
      help=('The milestone identifier '
            '(e.g. the milestone number for standard release channel)'))
  activate_parser.add_argument(
      '--branch',
      required=True,
      help='The branch name, must correspond to a ref in refs/branch-heads')

  deactivate_parser = subparsers.add_parser(
      'deactivate', help='Remove an active milestone')
  deactivate_parser.set_defaults(func=deactivate_cmd)
  deactivate_parser.add_argument(
      '--milestone',
      required=True,
      help=('The milestone identifier '
            '(e.g. the milestone number for standard release channel)'))

  args = parser.parse_args(args)
  if args.func is None:
    parser.error('no sub-command specified')
  return args