Fix completion script

This commit is contained in:
Thomas Scholtes 2014-07-08 17:52:46 +02:00
parent d2e848f75c
commit dc53f7907a
2 changed files with 7 additions and 7 deletions

View file

@ -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:

View file

@ -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']