Skip to content

Commit e6f251f

Browse files
committed
Merge branch 'master' into ansi_to_style
2 parents 97b821f + 97dd6f3 commit e6f251f

File tree

5 files changed

+26
-10
lines changed

5 files changed

+26
-10
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ precision = 1
2020

2121

2222
[html]
23-
# (string, default htmlcov): where to write the HTML report files.
23+
# (string, default "htmlcov"): where to write the HTML report files.
2424
directory = htmlcov

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## 0.9.23 (TBD, 2019)
22
* Bug Fixes
33
* Fixed bug where startup script containing a single quote in its file name was incorrectly quoted
4+
* Added missing implicit dependency on `setuptools` due to build with `setuptools_scm`
45
* Breaking changes
56
* Renamed the following `ansi` members for accuracy in what types of ANSI escape sequences are handled
67
* `ansi.allow_ansi` -> `ansi.allow_style`

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ The tables below list all prerequisites along with the minimum required version
5151
| [attrs](https://github.com/python-attrs/attrs) | `16.3` |
5252
| [colorama](https://github.com/tartley/colorama) | `0.3.7` |
5353
| [pyperclip](https://github.com/asweigart/pyperclip) | `1.6` |
54+
| [setuptools](https://pypi.org/project/setuptools/) | `34.4` |
5455
| [wcwidth](https://pypi.python.org/pypi/wcwidth) | `0.1.7` |
5556

5657

examples/dynamic_commands.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,32 @@
33
"""A simple example demonstrating how do_* commands can be created in a loop.
44
"""
55
import functools
6+
67
import cmd2
7-
COMMAND_LIST = ['foo', 'bar', 'baz']
8+
from cmd2.constants import COMMAND_FUNC_PREFIX, HELP_FUNC_PREFIX
9+
10+
COMMAND_LIST = ['foo', 'bar']
11+
CATEGORY = 'Dynamic Commands'
812

913

1014
class CommandsInLoop(cmd2.Cmd):
1115
"""Example of dynamically adding do_* commands."""
1216
def __init__(self):
17+
# Add dynamic commands before calling cmd2.Cmd's init since it validates command names
18+
for command in COMMAND_LIST:
19+
# Create command function and add help category to it
20+
cmd_func = functools.partial(self.send_text, text=command)
21+
cmd2.categorize(cmd_func, CATEGORY)
22+
23+
# Add command function to CLI object
24+
cmd_func_name = COMMAND_FUNC_PREFIX + command
25+
setattr(self, cmd_func_name, cmd_func)
26+
27+
# Add help function to CLI object
28+
help_func = functools.partial(self.text_help, text=command)
29+
help_func_name = HELP_FUNC_PREFIX + command
30+
setattr(self, help_func_name, help_func)
31+
1332
super().__init__(use_ipython=True)
1433

1534
def send_text(self, args: cmd2.Statement, *, text: str):
@@ -21,11 +40,6 @@ def text_help(self, *, text: str):
2140
self.poutput("Simulate sending {!r} to a server and printing the response".format(text))
2241

2342

24-
for command in COMMAND_LIST:
25-
setattr(CommandsInLoop, 'do_{}'.format(command), functools.partialmethod(CommandsInLoop.send_text, text=command))
26-
setattr(CommandsInLoop, 'help_{}'.format(command), functools.partialmethod(CommandsInLoop.text_help, text=command))
27-
28-
2943
if __name__ == '__main__':
3044
app = CommandsInLoop()
3145
app.cmdloop()

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
Topic :: Software Development :: Libraries :: Python Modules
3030
""".splitlines()))) # noqa: E128
3131

32-
SETUP_REQUIRES = ['setuptools_scm']
32+
SETUP_REQUIRES = ['setuptools_scm >= 3.0.0']
3333

34-
INSTALL_REQUIRES = ['pyperclip >= 1.6', 'colorama >= 0.3.7', 'attrs >= 16.3.0', 'wcwidth >= 0.1.7']
34+
INSTALL_REQUIRES = ['attrs >= 16.3.0', 'colorama >= 0.3.7', 'pyperclip >= 1.6', 'setuptools >= 34.4', 'wcwidth >= 0.1.7']
3535

3636
EXTRAS_REQUIRE = {
3737
# Windows also requires pyreadline to ensure tab completion works
3838
":sys_platform=='win32'": ['pyreadline'],
3939
# Extra dependencies for running unit tests
4040
'test': ["gnureadline; sys_platform=='darwin'", # include gnureadline on macOS to ensure it is available in tox env
4141
"mock ; python_version<'3.6'", # for python 3.5 we need the third party mock module
42-
'codecov', 'pytest', 'pytest-cov', 'pytest-mock'],
42+
'codecov', 'coverage', 'pytest', 'pytest-cov', 'pytest-mock'],
4343
# development only dependencies: install with 'pip install -e .[dev]'
4444
'dev': ["mock ; python_version<'3.6'", # for python 3.5 we need the third party mock module
4545
'pytest', 'codecov', 'pytest-cov', 'pytest-mock', 'tox', 'flake8',

0 commit comments

Comments
 (0)