Skip to content

Commit e38684d

Browse files
committed
Brought in cmd2 plugin template as a first-class member of cmd2 proper
1 parent 683d049 commit e38684d

File tree

17 files changed

+900
-16
lines changed

17 files changed

+900
-16
lines changed

noxfile.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ def docs(session):
1212

1313

1414
@nox.session(python=['3.5', '3.6', '3.7', '3.8', '3.9'])
15-
def tests(session):
16-
session.install('invoke', './[test]')
17-
session.run('invoke', 'pytest', '--junit', '--no-pty')
15+
@nox.parametrize('plugin', [None, 'ext_test', 'template'])
16+
def tests(session, plugin):
17+
if plugin is None:
18+
session.install('invoke', './[test]')
19+
session.run('invoke', 'pytest', '--junit', '--no-pty')
20+
else:
21+
session.install('invoke', '.')
1822

19-
# cd into test directory to run other unit test
20-
session.chdir('./plugins/ext_test')
21-
session.install('.[test]')
22-
session.run('invoke', 'pytest', '--junit', '--no-pty', '--append-cov')
23+
# cd into test directory to run other unit test
24+
session.install('plugins/{}[test]'.format(plugin))
25+
session.run('invoke', 'plugin.{}.pytest'.format(plugin.replace('_', '-')), '--junit', '--no-pty')
2326

24-
# return to top directory to submit coverage
25-
session.chdir('../..')
2627
session.run('codecov')

plugins/README.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
For information about creating a cmd2 plugin, see template/README.md

plugins/ext_test/cmd2_ext_test/cmd2_ext_test.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22
# coding=utf-8
33
"""External test interface plugin"""
44

5-
from typing import Optional
5+
from typing import Optional, TYPE_CHECKING
66

77
import cmd2
88

9+
if TYPE_CHECKING:
10+
_Base = cmd2.Cmd
11+
else:
12+
_Base = object
913

10-
class ExternalTestMixin:
14+
15+
class ExternalTestMixin(_Base):
1116
"""A cmd2 plugin (mixin class) that exposes an interface to execute application commands from python"""
1217

1318
def __init__(self, *args, **kwargs):

plugins/tasks.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,13 @@
99
- setuptools >= 39.1.0
1010
"""
1111
import os
12-
import re
13-
import shutil
14-
import sys
15-
1612
import invoke
1713

1814
from plugins.ext_test import tasks as ext_test_tasks
15+
from plugins.template import tasks as template_tasks
1916

2017
# create namespaces
21-
namespace = invoke.Collection()
18+
namespace = invoke.Collection(ext_test=ext_test_tasks, template=template_tasks)
2219
namespace_clean = invoke.Collection('clean')
2320
namespace.add_collection(namespace_clean, 'clean')
2421

plugins/template/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
## 1.0.0 (2018-07-24)
8+
9+
### Added
10+
- Created plugin template and initial documentation
11+
12+

plugins/template/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Jared Crapo
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)