From dc53f7907a9c5d5ea4fcb596d9f905f183d91bf6 Mon Sep 17 00:00:00 2001 From: Thomas Scholtes Date: Tue, 8 Jul 2014 17:52:46 +0200 Subject: [PATCH] Fix completion script --- beets/ui/__init__.py | 6 +++--- beets/ui/commands.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py index 4ab49d516..da78fbb3f 100644 --- a/beets/ui/__init__.py +++ b/beets/ui/__init__.py @@ -775,9 +775,9 @@ class SubcommandsOptionParser(optparse.OptionParser): return self.parse_args(args) def parse_subcommand(self, args): - """Given the `args` left unused by a typical OptionParser - `parse_args`, return the invoked subcommand, the subcommand - options, and the subcommand arguments. + """Given the `args` left unused by a `parse_global_options`, + return the invoked subcommand, the subcommand options, and the + subcommand arguments. """ # Help is default command if not args: diff --git a/beets/ui/commands.py b/beets/ui/commands.py index 69d373d82..14f2bf0a4 100644 --- a/beets/ui/commands.py +++ b/beets/ui/commands.py @@ -23,6 +23,7 @@ import time import itertools import codecs import platform +import re import beets from beets import ui @@ -111,6 +112,7 @@ fields_cmd = ui.Subcommand( fields_cmd.func = fields_func default_commands.append(fields_cmd) + # help: Print help text for commands class HelpCommand(ui.Subcommand): @@ -1521,7 +1523,8 @@ def completion_script(commands): command_names.append(name) for alias in cmd.aliases: - aliases[alias] = name + if re.match(r'^\w+$', alias): + aliases[alias] = name options[name] = {'flags': [], 'opts': []} for opts in cmd.parser._get_all_options()[1:]: @@ -1540,9 +1543,6 @@ def completion_script(commands): 'opts': '-l --library -c --config -d --directory -h --help'.split(' ') } - # Help subcommand - command_names.append('help') - # Add flags common to all commands options['_common'] = { 'flags': ['-h', '--help']