def create(self, argv): """ Create a new plugin. """ name = argv.name bundle = argv.bundle template = argv.template save_dir = argv.dir with self.out() as out: if template not in available_templates(): raise CommandError( 'Language {0} is not supported yet.'.format(template), hint=FORK_PROJECT_GITHUB) try: plugin_dir = create_plugin( save_dir, bundle, name, template=template) out.append('Created plugin as {0}'.format(plugin_dir)) except OSError as ose: if ose.errno == errno.EEXIST: # File exists raise CommandError( 'A plugin with this name already ' 'exists in this directory: {0}.'.format(save_dir)) # Something else, raise it again raise ose # pragma: no cover
def test_list_available_templates(self): """ List available templates for creating plugins. """ self.assertEqual(['python'], available_templates())
_removeparser.add_argument( '--gitrepo', '-r', default='.', dest='path', help='Path to the Git repository, default current directory') _removeparser.set_defaults(subcommand='remove') _createparser = _subparsers.add_parser( 'create', help='create a new plugin', usage='jig plugin create [-h] [-l TEMPLATE] [-d DIR] NAME BUNDLE') _createparser.add_argument( 'name', help='Plugin name') _createparser.add_argument( 'bundle', help='Bundle name') _createparser.add_argument( '--language', '-l', dest='template', default='python', help='Scripting language: {0}'.format( ', '.join(available_templates()))) _createparser.add_argument( '--dir', '-d', default='.', help='Create in this directory') _createparser.set_defaults(subcommand='create') _testparser = _subparsers.add_parser( 'test', help='run a suite of plugin tests', usage='jig plugin test [-h] [-r RANGE] PLUGIN') _testparser.add_argument( 'plugin', nargs='?', default='.', help='Path to the plugin directory') _testparser.add_argument( '--verbose', '-v', default=False, action='store_true', help='Print the input and output (stdin and stdout)')