Skip to content

Commit

Permalink
Avoid crashing 'beet completion'
Browse files Browse the repository at this point in the history
Add the `_get_all_options()` method to the argument parser so that `beet
completion` does not throw an error anymore.

Fixes #38
  • Loading branch information
Thomas Scholtes committed Sep 15, 2019
1 parent 5751eb7 commit 1d62902
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
13 changes: 11 additions & 2 deletions beetsplug/alternatives.py
Expand Up @@ -13,7 +13,7 @@

import os.path
import threading
from argparse import ArgumentParser
import argparse
from concurrent import futures
import six

Expand All @@ -26,7 +26,6 @@

from beetsplug import convert


class AlternativesPlugin(BeetsPlugin):

def __init__(self):
Expand Down Expand Up @@ -84,6 +83,16 @@ def parse_args(self, args):
return self.parser.parse_args(args), []


class ArgumentParser(argparse.ArgumentParser):
"""
Facade for ``argparse.ArgumentParser`` so that beets can call
`_get_all_options()` to generate shell completion.
"""
def _get_all_options(self):
# FIXME return options like ``OptionParser._get_all_options``.
return []


class External(object):

ADD = 1
Expand Down
9 changes: 9 additions & 0 deletions test/cli_test.py
Expand Up @@ -537,3 +537,12 @@ def test_not_removable(self):
self.assertNotIn('Do you want to create the collection?', out)
item.load()
self.assertIn('alt.myexternal', item)


class CompletionTest(TestHelper):
"""Test invocation of ``beet completion`` with this plugin.
Only ensures that command does not fail.
"""
def test_completion(self):
self.runcli('completion')

0 comments on commit 1d62902

Please sign in to comment.