/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5147.5.4 by Martin von Gagern
Assign copyright to Canonical Ltd.
1
# Copyright (C) 2009, 2010 Canonical Ltd
0.27.14 by Martin von Gagern
Added GPL 2 license document and copyright notice.
2
#
5147.5.5 by Martin von Gagern
Adjust copyright notice comments for bash_completion.
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
0.27.14 by Martin von Gagern
Added GPL 2 license document and copyright notice.
12
#
13
# You should have received a copy of the GNU General Public License
5147.5.5 by Martin von Gagern
Adjust copyright notice comments for bash_completion.
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0.27.14 by Martin von Gagern
Added GPL 2 license document and copyright notice.
16
0.27.11 by Martin von Gagern
Add module docstring.
17
"""Generate a shell function for bash command line completion.
18
19
This plugin provides a command called bash-completion that generates a
20
bash completion function for bzr. See its documentation for details.
21
"""
22
0.27.16 by Martin von Gagern
Added distutils setup script and plugin meta data.
23
from meta import *
24
from meta import __version__
25
0.27.2 by Martin von Gagern
First programmatic generation of completions.
26
from bzrlib.commands import Command, register_command
0.27.38 by Martin von Gagern
Add --plugin switch to selectively include plugins.
27
from bzrlib.option import Option, ListOption
0.27.2 by Martin von Gagern
First programmatic generation of completions.
28
29
class cmd_bash_completion(Command):
30
    """Generate a shell function for bash command line completion.
31
32
    This command generates a shell function which can be used by bash to
33
    automatically complete the currently typed command when the user presses
34
    the completion key (usually tab).
35
    
36
    Commonly used like this:
37
        eval "`bzr bash-completion`"
38
    """
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
39
40
    takes_options = [
41
        Option("function-name", short_name="f", type=str, argname="name",
0.27.8 by Martin von Gagern
Shorter help message for --function-name
42
               help="Name of the generated function (default: _bzr)"),
0.27.7 by Martin von Gagern
Introduce --function-only option
43
        Option("function-only", short_name="o", type=None,
44
               help="Generate only the shell function, don't enable it"),
0.27.31 by Martin von Gagern
Introduce --debug switch to enable some debugging code.
45
        Option("debug", type=None, hidden=True,
46
               help="Enable shell code useful for debugging"),
0.27.38 by Martin von Gagern
Add --plugin switch to selectively include plugins.
47
        ListOption("plugin", type=str, argname="name",
48
                   # param_name="selected_plugins", # doesn't work, bug #387117
49
                   help="Enable completions for the selected plugin"
50
                   + " (default: all plugins)"),
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
51
        ]
52
53
    def run(self, **kwargs):
0.27.2 by Martin von Gagern
First programmatic generation of completions.
54
        import sys
55
        from bashcomp import bash_completion_function
0.27.38 by Martin von Gagern
Add --plugin switch to selectively include plugins.
56
        if 'plugin' in kwargs:
57
            # work around bug #387117 which prevents us from using param_name
58
            kwargs['selected_plugins'] = kwargs['plugin']
59
            del kwargs['plugin']
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
60
        bash_completion_function(sys.stdout, **kwargs)
0.27.2 by Martin von Gagern
First programmatic generation of completions.
61
62
register_command(cmd_bash_completion)