summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-01-07 12:45:36 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-01-07 12:45:36 -0500
commite6f251fd733236cfe0dbd9ebb9393dd487668c8e (patch)
tree6a585ef06bcae1938d8974a060f82f966db004f1
parent97b821f10913c82843c2278c70805e3d39cd2076 (diff)
parent97dd6f37482510cfc424049ff0b0369b79e34335 (diff)
downloadcmd2-git-e6f251fd733236cfe0dbd9ebb9393dd487668c8e.tar.gz
Merge branch 'master' into ansi_to_style
-rw-r--r--.coveragerc2
-rw-r--r--CHANGELOG.md1
-rw-r--r--CONTRIBUTING.md1
-rwxr-xr-xexamples/dynamic_commands.py26
-rwxr-xr-xsetup.py6
5 files changed, 26 insertions, 10 deletions
diff --git a/.coveragerc b/.coveragerc
index 307e3a9a..96bf5d72 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -20,5 +20,5 @@ precision = 1
[html]
-# (string, default “htmlcov”): where to write the HTML report files.
+# (string, default "htmlcov"): where to write the HTML report files.
directory = htmlcov
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 72dedb06..9dcb2a12 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,7 @@
## 0.9.23 (TBD, 2019)
* Bug Fixes
* Fixed bug where startup script containing a single quote in its file name was incorrectly quoted
+ * Added missing implicit dependency on `setuptools` due to build with `setuptools_scm`
* Breaking changes
* Renamed the following `ansi` members for accuracy in what types of ANSI escape sequences are handled
* `ansi.allow_ansi` -> `ansi.allow_style`
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6055fa7d..96c2d312 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -51,6 +51,7 @@ The tables below list all prerequisites along with the minimum required version
| [attrs](https://github.com/python-attrs/attrs) | `16.3` |
| [colorama](https://github.com/tartley/colorama) | `0.3.7` |
| [pyperclip](https://github.com/asweigart/pyperclip) | `1.6` |
+| [setuptools](https://pypi.org/project/setuptools/) | `34.4` |
| [wcwidth](https://pypi.python.org/pypi/wcwidth) | `0.1.7` |
diff --git a/examples/dynamic_commands.py b/examples/dynamic_commands.py
index 69816d40..620acb7f 100755
--- a/examples/dynamic_commands.py
+++ b/examples/dynamic_commands.py
@@ -3,13 +3,32 @@
"""A simple example demonstrating how do_* commands can be created in a loop.
"""
import functools
+
import cmd2
-COMMAND_LIST = ['foo', 'bar', 'baz']
+from cmd2.constants import COMMAND_FUNC_PREFIX, HELP_FUNC_PREFIX
+
+COMMAND_LIST = ['foo', 'bar']
+CATEGORY = 'Dynamic Commands'
class CommandsInLoop(cmd2.Cmd):
"""Example of dynamically adding do_* commands."""
def __init__(self):
+ # Add dynamic commands before calling cmd2.Cmd's init since it validates command names
+ for command in COMMAND_LIST:
+ # Create command function and add help category to it
+ cmd_func = functools.partial(self.send_text, text=command)
+ cmd2.categorize(cmd_func, CATEGORY)
+
+ # Add command function to CLI object
+ cmd_func_name = COMMAND_FUNC_PREFIX + command
+ setattr(self, cmd_func_name, cmd_func)
+
+ # Add help function to CLI object
+ help_func = functools.partial(self.text_help, text=command)
+ help_func_name = HELP_FUNC_PREFIX + command
+ setattr(self, help_func_name, help_func)
+
super().__init__(use_ipython=True)
def send_text(self, args: cmd2.Statement, *, text: str):
@@ -21,11 +40,6 @@ class CommandsInLoop(cmd2.Cmd):
self.poutput("Simulate sending {!r} to a server and printing the response".format(text))
-for command in COMMAND_LIST:
- setattr(CommandsInLoop, 'do_{}'.format(command), functools.partialmethod(CommandsInLoop.send_text, text=command))
- setattr(CommandsInLoop, 'help_{}'.format(command), functools.partialmethod(CommandsInLoop.text_help, text=command))
-
-
if __name__ == '__main__':
app = CommandsInLoop()
app.cmdloop()
diff --git a/setup.py b/setup.py
index b59d72ff..b19ae7f5 100755
--- a/setup.py
+++ b/setup.py
@@ -29,9 +29,9 @@ Programming Language :: Python :: Implementation :: CPython
Topic :: Software Development :: Libraries :: Python Modules
""".splitlines()))) # noqa: E128
-SETUP_REQUIRES = ['setuptools_scm']
+SETUP_REQUIRES = ['setuptools_scm >= 3.0.0']
-INSTALL_REQUIRES = ['pyperclip >= 1.6', 'colorama >= 0.3.7', 'attrs >= 16.3.0', 'wcwidth >= 0.1.7']
+INSTALL_REQUIRES = ['attrs >= 16.3.0', 'colorama >= 0.3.7', 'pyperclip >= 1.6', 'setuptools >= 34.4', 'wcwidth >= 0.1.7']
EXTRAS_REQUIRE = {
# Windows also requires pyreadline to ensure tab completion works
@@ -39,7 +39,7 @@ EXTRAS_REQUIRE = {
# Extra dependencies for running unit tests
'test': ["gnureadline; sys_platform=='darwin'", # include gnureadline on macOS to ensure it is available in tox env
"mock ; python_version<'3.6'", # for python 3.5 we need the third party mock module
- 'codecov', 'pytest', 'pytest-cov', 'pytest-mock'],
+ 'codecov', 'coverage', 'pytest', 'pytest-cov', 'pytest-mock'],
# development only dependencies: install with 'pip install -e .[dev]'
'dev': ["mock ; python_version<'3.6'", # for python 3.5 we need the third party mock module
'pytest', 'codecov', 'pytest-cov', 'pytest-mock', 'tox', 'flake8',