/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.27.2 by Martin von Gagern
First programmatic generation of completions.
1
from bzrlib.commands import Command, register_command
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
2
from bzrlib.option import Option
0.27.2 by Martin von Gagern
First programmatic generation of completions.
3
4
class cmd_bash_completion(Command):
5
    """Generate a shell function for bash command line completion.
6
7
    This command generates a shell function which can be used by bash to
8
    automatically complete the currently typed command when the user presses
9
    the completion key (usually tab).
10
    
11
    Commonly used like this:
12
        eval "`bzr bash-completion`"
13
    """
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
14
15
    takes_options = [
16
        Option("function-name", short_name="f", type=str, argname="name",
0.27.8 by Martin von Gagern
Shorter help message for --function-name
17
               help="Name of the generated function (default: _bzr)"),
0.27.7 by Martin von Gagern
Introduce --function-only option
18
        Option("function-only", short_name="o", type=None,
19
               help="Generate only the shell function, don't enable it"),
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
20
        ]
21
22
    def run(self, **kwargs):
0.27.2 by Martin von Gagern
First programmatic generation of completions.
23
        import sys
24
        from bashcomp import bash_completion_function
0.27.4 by Martin von Gagern
Introduce --function-name switch. (LP #439829)
25
        bash_completion_function(sys.stdout, **kwargs)
0.27.2 by Martin von Gagern
First programmatic generation of completions.
26
27
register_command(cmd_bash_completion)