Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid crashing 'beet completion' #39

Merged
merged 1 commit into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')