code: def parse_competitions(subparsers):
      if six.PY2:
          parser_competitions = subparsers.add_parser(
              "competitions",
              formatter_class=argparse.RawTextHelpFormatter,
              help=Help.group_competitions,
          )
      else:
          parser_competitions = subparsers.add_parser(
              "competitions",
              formatter_class=argparse.RawTextHelpFormatter,
              help=Help.group_competitions,
              aliases=["c"],
          )
      subparsers_competitions = parser_competitions.add_subparsers(
          title="commands", dest="command"
      )
      subparsers_competitions.required = True
      subparsers_competitions.choices = Help.competitions_choices
  
      # Competitions list
      parser_competitions_list = subparsers_competitions.add_parser(
          "list",
          formatter_class=argparse.RawTextHelpFormatter,
          help=Help.command_competitions_list,
      )
      parser_competitions_list_optional = (
          parser_competitions_list._action_groups.pop()
      )
      parser_competitions_list_optional.add_argument(
          "--group",
          dest="group",
          required=False,
          help=Help.param_competition_group,
      )
      parser_competitions_list_optional.add_argument(
          "--category",
          dest="category",
          required=False,
          help=Help.param_competition_category,
      )
      parser_competitions_list_optional.add_argument(
          "--sort-by",
          dest="sort_by",
          required=False,
          help=Help.param_competition_sort_by,
      )
      parser_competitions_list_optional.add_argument(
          "-p",
          "--page",
          dest="page",
          default=1,
          required=False,
          help=Help.param_page,
      )
      parser_competitions_list_optional.add_argument(
          "-s",
          "--search",
          dest="search",
          required=False,
          help=Help.param_search,
      )
      parser_competitions_list_optional.add_argument(
          "-v",
          "--csv",
          dest="csv_display",
          action="store_true",
          help=Help.param_csv,
      )
      parser_competitions_list._action_groups.append(
          parser_competitions_list_optional
      )
      parser_competitions_list.set_defaults(
          func=api.competitions_list_cli
      )
  
      # Competitions list files
      parser_competitions_files = subparsers_competitions.add_parser(
          "files",
          formatter_class=argparse.RawTextHelpFormatter,
          help=Help.command_competitions_files,
      )
      parser_competitions_files_optional = (
          parser_competitions_files._action_groups.pop()
      )
      parser_competitions_files_optional.add_argument(
          "competition",
          nargs="?",
          default=None,
          help=Help.param_competition,
      )
      parser_competitions_files_optional.add_argument(
          "-c",
          "--competition",
          dest="competition_opt",
          required=False,
          help=argparse.SUPPRESS,
      )
      parser_competitions_files_optional.add_argument(
          "-v",
          "--csv",
          dest="csv_display",
          action="store_true",
          help=Help.param_csv,
      )
      parser_competitions_files_optional.add_argument(
          "-q",
          "--quiet",
          dest="quiet",
          action="store_true",
          help=Help.param_quiet,
      )
      parser_competitions_files._action_groups.append(
          parser_competitions_files_optional
      )
      parser_competitions_files.set_defaults(
          func=api.competition_list_files_cli
      )
  
      # Competitions download
      parser_competitions_download = subparsers_competitions.add_parser(
          "download",
          formatter_class=argparse.RawTextHelpFormatter,
          help=Help.command_competitions_download,
      )
      parser_competitions_download_optional = (
          parser_competitions_download._action_groups.pop()
      )
      parser_competitions_download_optional.add_argument(
          "competition",
          nargs="?",
          default=None,
          help=Help.param_competition,
      )
      parser_competitions_download_optional.add_argument(
          "-c",
          "--competition",
          dest="competition_opt",
          required=False,
          help=argparse.SUPPRESS,
      )
      parser_competitions_download_optional.add_argument(
          "-f",
          "--file",
          dest="file_name",
          required=False,
          help=Help.param_competition_file,
      )
      parser_competitions_download_optional.add_argument(
          "-p",
          "--path",
          dest="path",
          required=False,
          help=Help.param_downfolder,
      )
      parser_competitions_download_optional.add_argument(
          "-w",
          "--wp",
          dest="path",
          action="store_const",
          const=".",
          required=False,
          help=Help.param_wp,
      )
      parser_competitions_download_optional.add_argument(
          "-o",
          "--force",
          dest="force",
          action="store_true",
          help=Help.param_force,
      )
      parser_competitions_download_optional.add_argument(
          "-q",
          "--quiet",
          dest="quiet",
          action="store_true",
          help=Help.param_quiet,
      )
      parser_competitions_download._action_groups.append(
          parser_competitions_download_optional
      )
      parser_competitions_download.set_defaults(
          func=api.competition_download_cli
      )
  
      # Competitions submit
      parser_competitions_submit = subparsers_competitions.add_parser(
          "submit",
          formatter_class=argparse.RawTextHelpFormatter,
          help=Help.command_competitions_submit,
      )
      parser_competitions_submit_optional = (
          parser_competitions_submit._action_groups.pop()
      )
      parser_competitions_submit_required = (
          parser_competitions_submit.add_argument_group(
              "required arguments"
          )
      )
      parser_competitions_submit_optional.add_argument(
          "competition",
          nargs="?",
          default=None,
          help=Help.param_competition,
      )
      parser_competitions_submit_optional.add_argument(
          "-c",
          "--competition",
          dest="competition_opt",
          required=False,
          help=argparse.SUPPRESS,
      )
      parser_competitions_submit_required.add_argument(
          "-f",
          "--file",
          dest="file_name",
          required=True,
          help=Help.param_upfile,
      )
      parser_competitions_submit_required.add_argument(
          "-m",
          "--message",
          dest="message",
          required=True,
          help=Help.param_competition_message,
      )
      parser_competitions_submit_optional.add_argument(
          "-q",
          "--quiet",
          dest="quiet",
          action="store_true",
          help=Help.param_quiet,
      )
      parser_competitions_submit._action_groups.append(
          parser_competitions_submit_optional
      )
      parser_competitions_submit.set_defaults(
          func=api.competition_submit_cli
      )
  
      # Competitions list submissions
      parser_competitions_submissions = (
          subparsers_competitions.add_parser(
              "submissions",
              formatter_class=argparse.RawTextHelpFormatter,
              help=Help.command_competitions_submissions,
          )
      )
      parser_competitions_submissions_optional = (
          parser_competitions_submissions._action_groups.pop()
      )
      parser_competitions_submissions_optional.add_argument(
          "competition",
          nargs="?",
          default=None,
          help=Help.param_competition,
      )
      parser_competitions_submissions_optional.add_argument(
          "-c",
          "--competition",
          dest="competition_opt",
          required=False,
          help=argparse.SUPPRESS,
      )
      parser_competitions_submissions_optional.add_argument(
          "-v",
          "--csv",
          dest="csv_display",
          action="store_true",
          help=Help.param_csv,
      )
      parser_competitions_submissions_optional.add_argument(
          "-q",
          "--quiet",
          dest="quiet",
          action="store_true",
          help=Help.param_quiet,
      )
      parser_competitions_submissions._action_groups.append(
          parser_competitions_submissions_optional
      )
      parser_competitions_submissions.set_defaults(
          func=api.competition_submissions_cli
      )
  
      # Competitions leaderboard
      parser_competitions_leaderboard = (
          subparsers_competitions.add_parser(
              "leaderboard",
              formatter_class=argparse.RawTextHelpFormatter,
              help=Help.command_competitions_leaderboard,
          )
      )
      parser_competitions_leaderboard_optional = (
          parser_competitions_leaderboard._action_groups.pop()
      )
      parser_competitions_leaderboard_optional.add_argument(
          "competition",
          nargs="?",
          default=None,
          help=Help.param_competition,
      )
      parser_competitions_leaderboard_optional.add_argument(
          "-c",
          "--competition",
          dest="competition_opt",
          required=False,
          help=argparse.SUPPRESS,
      )
      parser_competitions_leaderboard_optional.add_argument(
          "-s",
          "--show",
          dest="view",
          action="store_true",
          help=Help.param_competition_leaderboard_view,
      )
      parser_competitions_leaderboard_optional.add_argument(
          "-d",
          "--download",
          dest="download",
          action="store_true",
          help=Help.param_competition_leaderboard_download,
      )
      parser_competitions_leaderboard_optional.add_argument(
          "-p", "--path", dest="path", help=Help.param_downfolder
      )
      parser_competitions_leaderboard_optional.add_argument(
          "-v",
          "--csv",
          dest="csv_display",
          action="store_true",
          help=Help.param_csv,
      )
      parser_competitions_leaderboard_optional.add_argument(
          "-q",
          "--quiet",
          dest="quiet",
          action="store_true",
          help=Help.param_quiet,
      )
      parser_competitions_leaderboard._action_groups.append(
          parser_competitions_leaderboard_optional
      )
      parser_competitions_leaderboard.set_defaults(
          func=api.competition_leaderboard_cli
      )
  
file_path: kaggle-api/kaggle/cli.py
imports: from __future__ import print_function
  import argparse
  import json
  from kaggle import api
  from kaggle import KaggleApi
  from .rest import ApiException
  import six
label_desc: Use image node_id 3 for calling a global function with example usage: parse_competitions(subparsers) without return types