diff options
author | Doug Hellmann <doug.hellmann@gmail.com> | 2013-03-13 16:08:18 -0700 |
---|---|---|
committer | Doug Hellmann <doug.hellmann@gmail.com> | 2013-03-13 16:08:18 -0700 |
commit | 5233a27fe56b20865c9c96737f3824c1d51c1d88 (patch) | |
tree | 6ea9a74dcb83269b5af86fcd2f26f13ff223d82f | |
parent | 1f34d45e325f3e3e965b22dcf43820e3d8c4f1e6 (diff) | |
parent | e534f03345a4f4411118134301181dd43f0decda (diff) | |
download | cliff-5233a27fe56b20865c9c96737f3824c1d51c1d88.tar.gz |
Merge pull request #31 from jserver/master
Make converting underscores optional in CommandManager
-rw-r--r-- | cliff/commandmanager.py | 8 | ||||
-rw-r--r-- | docs/source/history.rst | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/cliff/commandmanager.py b/cliff/commandmanager.py index 135714a..754f793 100644 --- a/cliff/commandmanager.py +++ b/cliff/commandmanager.py @@ -27,16 +27,20 @@ class CommandManager(object): :param namespace: String containing the setuptools entrypoint namespace for the plugins to be loaded. For example, ``'cliff.formatter.list'``. + :param convert_underscores: Whether cliff should convert underscores to + to spaces in entry_point commands. """ - def __init__(self, namespace): + def __init__(self, namespace, convert_underscores=True): self.commands = {} self.namespace = namespace + self.convert_underscores = convert_underscores self._load_commands() def _load_commands(self): for ep in pkg_resources.iter_entry_points(self.namespace): LOG.debug('found command %r', ep.name) - self.commands[ep.name.replace('_', ' ')] = ep + cmd_name = ep.name.replace('_', ' ') if self.convert_underscores else ep.name + self.commands[cmd_name] = ep return def __iter__(self): diff --git a/docs/source/history.rst b/docs/source/history.rst index f7348e9..8f4595a 100644 --- a/docs/source/history.rst +++ b/docs/source/history.rst @@ -2,6 +2,13 @@ Release History ================= +dev + + - Add ``convert_underscores`` parameter to ``CommandManager`` ``__init__`` + method to allow underscores to be used in command names. This optional + argument is defaulted to True to maintain current behavior. + (contributed by Joe Server) + 1.3.1 - Sort list of commands in interactive help mode. (contributed by |