62
62
complete -F %(function_name)s -o default brz
64
64
"function_name": self.function_name,
65
65
"function": self.function(),
66
66
"brz_version": self.brz_version(),
303
303
self.selected_plugins = None
305
305
self.selected_plugins = {x.replace('-', '_')
306
for x in selected_plugins}
306
for x in selected_plugins}
308
308
def collect(self):
309
309
self.global_options()
337
337
plugin_name = cmd.plugin_name()
338
338
if plugin_name is not None:
339
339
if (self.selected_plugins is not None and
340
plugin not in self.selected_plugins):
340
plugin not in self.selected_plugins):
342
342
plugin_data = self.data.plugins.get(plugin_name)
343
343
if plugin_data is None:
352
352
# ones while maintaining the actual command name unchanged.
353
353
cmd_data.aliases.extend(cmd.aliases)
354
354
cmd_data.aliases.extend(sorted([useralias
355
for cmdalias in cmd_data.aliases
356
if cmdalias in self.user_aliases
357
for useralias in self.user_aliases[cmdalias]
358
if useralias not in cmd_data.aliases]))
355
for cmdalias in cmd_data.aliases
356
if cmdalias in self.user_aliases
357
for useralias in self.user_aliases[cmdalias]
358
if useralias not in cmd_data.aliases]))
360
360
opts = cmd.options()
361
361
for optname, opt in sorted(opts.items()):
395
395
def wrap_parser(self, optswitches, parser):
396
396
orig_add_option_group = parser.add_option_group
397
398
def tweaked_add_option_group(*opts, **attrs):
398
399
return self.wrap_container(optswitches,
399
orig_add_option_group(*opts, **attrs))
400
orig_add_option_group(*opts, **attrs))
400
401
parser.add_option_group = tweaked_add_option_group
401
402
return self.wrap_container(optswitches, parser)
404
405
def bash_completion_function(out, function_name="_brz", function_only=False,
406
407
no_plugins=False, selected_plugins=None):
407
dc = DataCollector(no_plugins=no_plugins, selected_plugins=selected_plugins)
408
dc = DataCollector(no_plugins=no_plugins,
409
selected_plugins=selected_plugins)
408
410
data = dc.collect()
409
411
cg = BashCodeGen(data, function_name=function_name, debug=debug)
410
412
if function_only:
428
430
takes_options = [
429
431
option.Option("function-name", short_name="f", type=text_type, argname="name",
430
help="Name of the generated function (default: _brz)"),
432
help="Name of the generated function (default: _brz)"),
431
433
option.Option("function-only", short_name="o", type=None,
432
help="Generate only the shell function, don't enable it"),
434
help="Generate only the shell function, don't enable it"),
433
435
option.Option("debug", type=None, hidden=True,
434
help="Enable shell code useful for debugging"),
436
help="Enable shell code useful for debugging"),
435
437
option.ListOption("plugin", type=text_type, argname="name",
436
# param_name="selected_plugins", # doesn't work, bug #387117
437
help="Enable completions for the selected plugin"
438
+ " (default: all plugins)"),
438
# param_name="selected_plugins", # doesn't work, bug #387117
439
help="Enable completions for the selected plugin"
440
+ " (default: all plugins)"),
441
443
def run(self, **kwargs):