diff --git a/CHANGELOG.md b/CHANGELOG.md index 349fb6a..897fb5a 100644 --- a/CHANGELOG.md +++ b/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) diff --git a/beetsplug/alternatives.py b/beetsplug/alternatives.py index 8f98b57..db141e5 100644 --- a/beetsplug/alternatives.py +++ b/beetsplug/alternatives.py @@ -13,7 +13,7 @@ import os.path import threading -from argparse import ArgumentParser +import argparse from concurrent import futures import six @@ -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 diff --git a/test/cli_test.py b/test/cli_test.py index fb65b93..43282be 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -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')