1f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)# Copyright 2013 The Chromium Authors. All rights reserved.
2f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)# Use of this source code is governed by a BSD-style license that can be
3f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)# found in the LICENSE file.
4f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
5f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)"""Bash auto completion support.
6f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
7f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)Contains the special mode that returns lists of possible completions for the
8f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)current command line.
9f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)"""
10f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
11f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)import cr
12f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
13f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
14effb81e5f8246d0db0270817048dc992db66e9fbBen Murdochdef Complete():
15f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  """Attempts to build a completion list for the current command line.
16f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
17f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  COMP_WORD contains the word that is being completed, and COMP_CWORD has
18f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  the index of that word on the command line.
19f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  """
20f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)
21f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  # TODO(iancottrell): support auto complete of more than just the command
22f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  # try to parse the command line using parser
23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles)  print ' '.join(command.name for command in cr.Command.Plugins())
24