Skip to content

Commit

Permalink
Merge pull request #39 from geigerzaehler/completion-fix
Browse files Browse the repository at this point in the history
Avoid crashing 'beet completion'
  • Loading branch information
wisp3rwind authored Sep 18, 2019
2 parents 5751eb7 + a01d5d6 commit 1bc8752
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
12 changes: 11 additions & 1 deletion beetsplug/alternatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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

Expand Down Expand Up @@ -84,6 +84,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
Original file line number Diff line number Diff line change
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 1bc8752

Please sign in to comment.