/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.27.14 by Martin von Gagern
Added GPL 2 license document and copyright notice.
1
# Copyright (C) 2009, 2010  Martin von Gagern
2
#
3
# This file is part of bzr-bash-completion
4
#
5
# bzr-bash-completion free software: you can redistribute it and/or
6
# modify it under the terms of the GNU General Public License as
7
# published by the Free Software Foundation, either version 2 of the
8
# License, or (at your option) any later version.
9
#
10
# bzr-bash-completion is distributed in the hope that it will be
11
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
0.27.11 by Martin von Gagern
Add module docstring.
18
"""Generate a shell function for bash command line completion.
19
20
This plugin provides a command called bash-completion that generates a
21
bash completion function for bzr. See its documentation for details.
22
"""
23
0.27.16 by Martin von Gagern
Added distutils setup script and plugin meta data.
24
from meta import *
25
from meta import __version__
26
0.27.2 by Martin von Gagern
First programmatic generation of completions.
27
from bzrlib.commands import Command, register_command
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
28
from bzrlib.option import Option
0.27.2 by Martin von Gagern
First programmatic generation of completions.
29
30
class cmd_bash_completion(Command):
31
    """Generate a shell function for bash command line completion.
32
33
    This command generates a shell function which can be used by bash to
34
    automatically complete the currently typed command when the user presses
35
    the completion key (usually tab).
36
    
37
    Commonly used like this:
38
        eval "`bzr bash-completion`"
39
    """
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
40
41
    takes_options = [
42
        Option("function-name", short_name="f", type=str, argname="name",
0.27.8 by Martin von Gagern
Shorter help message for --function-name
43
               help="Name of the generated function (default: _bzr)"),
0.27.7 by Martin von Gagern
Introduce --function-only option
44
        Option("function-only", short_name="o", type=None,
45
               help="Generate only the shell function, don't enable it"),
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
46
        ]
47
48
    def run(self, **kwargs):
0.27.2 by Martin von Gagern
First programmatic generation of completions.
49
        import sys
50
        from bashcomp import bash_completion_function
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
51
        bash_completion_function(sys.stdout, **kwargs)
0.27.2 by Martin von Gagern
First programmatic generation of completions.
52
53
register_command(cmd_bash_completion)