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 3296fd8
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
@@ -1,8 +1,12 @@
Change Log
==========

## v0.10.0 - 2019-08-25
## Upcoming
* Running `beet completion` does not crash anymore [#38][]

[#38]: https://github.com/geigerzaehler/beets-alternatives/issues/38

## v0.10.0 - 2019-08-25
* Symlink views now support relative symlinks (@daviddavo)
* Running just `beet alt` does not throw an error anymore (@daviddavo)

Expand Down
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 3296fd8

Please sign in to comment.