def get_autocomplete_options_by_scope(self):
    """Return all cmd-line options.

    These are of two types: scoped and unscoped.  Scoped options are explicitly scoped
    (e.g., --goal-task-foo-bar) and may appear anywhere on the cmd line. Unscoped options
    may only appear in the appropriate cmd line scope (e.g., ./pants goal.task --foo-bar).

    Technically, any scoped option can appear anywhere, but in practice, having so many
    autocomplete options is more confusing than useful. So, as a heuristic:
     1. In global scope we only autocomplete globally-registered options.
     2. In a goal scope we only autocomplete options registered by any task in that goal.
     3. In a task scope we only autocomplete options registered by that task.

    :return: A map of scope -> options to complete at that scope.
    """
    autocomplete_options_by_scope = defaultdict(set)
    def get_from_parser(parser):
      oschi = HelpInfoExtracter.get_option_scope_help_info_from_parser(parser)
      # We ignore advanced options, as they aren't intended to be used on the cmd line.
      option_help_infos = oschi.basic + oschi.recursive
      for ohi in option_help_infos:
        autocomplete_options_by_scope[oschi.scope].update(ohi.unscoped_cmd_line_args)
        autocomplete_options_by_scope[oschi.scope].update(ohi.scoped_cmd_line_args)
        # Autocomplete to this option in the enclosing goal scope, but exclude options registered
        # on us, but not by us, e.g., recursive options (which are registered by
        # GlobalOptionsRegisterer).
        # We exclude those because they are already registered on the goal scope anyway
        # (via the recursion) and it would be confusing and superfluous to have autocompletion
        # to both --goal-recursive-opt and --goal-task-recursive-opt in goal scope.
        if issubclass(ohi.registering_class, TaskBase):
          goal_scope = oschi.scope.partition('.')[0]
          autocomplete_options_by_scope[goal_scope].update(ohi.scoped_cmd_line_args)
    self.context.options.walk_parsers(get_from_parser)
    return autocomplete_options_by_scope
def get_autocomplete_options_by_scope ( self ) : autocomplete_options_by_scope = defaultdict ( set ) def get_from_parser ( parser ) : oschi = HelpInfoExtracter . get_option_scope_help_info_from_parser ( parser ) option_help_infos = oschi . basic + oschi . recursive for ohi in option_help_infos : autocomplete_options_by_scope [ oschi . scope ] . update ( ohi . unscoped_cmd_line_args ) autocomplete_options_by_scope [ oschi . scope ] . update ( ohi . scoped_cmd_line_args ) if issubclass ( ohi . registering_class , TaskBase ) : goal_scope = oschi . scope . partition ( '.' ) [ 0 ] autocomplete_options_by_scope [ goal_scope ] . update ( ohi . scoped_cmd_line_args ) self . context . options . walk_parsers ( get_from_parser ) return autocomplete_options_by_scope
Return all cmd-line options.

    These are of two types: scoped and unscoped.  Scoped options are explicitly scoped
    (e.g., --goal-task-foo-bar) and may appear anywhere on the cmd line. Unscoped options
    may only appear in the appropriate cmd line scope (e.g., ./pants goal.task --foo-bar).

    Technically, any scoped option can appear anywhere, but in practice, having so many
    autocomplete options is more confusing than useful. So, as a heuristic:
     1. In global scope we only autocomplete globally-registered options.
     2. In a goal scope we only autocomplete options registered by any task in that goal.
     3. In a task scope we only autocomplete options registered by that task.

    :return: A map of scope -> options to complete at that scope.