mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-10-09 23:25:23 +00:00
初始化
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
|
||||
from plugin_framework import CCPluginFramework
|
@@ -0,0 +1,31 @@
|
||||
|
||||
import cocos
|
||||
from MultiLanguage import MultiLanguage
|
||||
|
||||
from package.helper import ProjectHelper
|
||||
|
||||
|
||||
class FrameworkAdd(cocos.CCPlugin):
|
||||
@staticmethod
|
||||
def plugin_name():
|
||||
return "add-framework"
|
||||
|
||||
@staticmethod
|
||||
def brief_description():
|
||||
return MultiLanguage.get_string('FRAMEWORK_ADD_BRIEF')
|
||||
|
||||
# parse arguments
|
||||
def parse_args(self, argv):
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser(prog="cocos %s" % self.__class__.plugin_name(),
|
||||
description=self.__class__.brief_description())
|
||||
parser.add_argument("name", metavar="NAME", help=MultiLanguage.get_string('FRAMEWORK_ADD_ARG_NAME'))
|
||||
return parser.parse_args(argv)
|
||||
|
||||
def run(self, argv):
|
||||
args = self.parse_args(argv)
|
||||
name = args.name
|
||||
|
||||
project = ProjectHelper.get_current_project()
|
||||
ProjectHelper.add_framework(project, name)
|
@@ -0,0 +1,31 @@
|
||||
|
||||
import cocos
|
||||
from MultiLanguage import MultiLanguage
|
||||
|
||||
from package.helper import ProjectHelper
|
||||
|
||||
|
||||
class FrameworkCreate(cocos.CCPlugin):
|
||||
@staticmethod
|
||||
def plugin_name():
|
||||
return "create-framework"
|
||||
|
||||
@staticmethod
|
||||
def brief_description():
|
||||
return MultiLanguage.get_string('FRAMEWORK_CREATE_BRIEF')
|
||||
|
||||
# parse arguments
|
||||
def parse_args(self, argv):
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser(prog="cocos %s" % self.__class__.plugin_name(),
|
||||
description=self.__class__.brief_description())
|
||||
parser.add_argument("name", metavar="NAME", help=MultiLanguage.get_string('FRAMEWORK_CREATE_ARG_NAME'))
|
||||
return parser.parse_args(argv)
|
||||
|
||||
def run(self, argv):
|
||||
args = self.parse_args(argv)
|
||||
name = args.name
|
||||
|
||||
project = ProjectHelper.get_current_project()
|
||||
ProjectHelper.create_framework(project, name)
|
@@ -0,0 +1,31 @@
|
||||
|
||||
import cocos
|
||||
from MultiLanguage import MultiLanguage
|
||||
|
||||
from package.helper import ProjectHelper
|
||||
|
||||
|
||||
class FrameworkRemove(cocos.CCPlugin):
|
||||
@staticmethod
|
||||
def plugin_name():
|
||||
return "remove-framework"
|
||||
|
||||
@staticmethod
|
||||
def brief_description():
|
||||
return MultiLanguage.get_string('FRAMEWORK_REMOVE_BRIEF')
|
||||
|
||||
# parse arguments
|
||||
def parse_args(self, argv):
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser(prog="cocos %s" % self.__class__.plugin_name(),
|
||||
description=self.__class__.brief_description())
|
||||
parser.add_argument("name", metavar="NAME", help=MultiLanguage.get_string('FRAMEWORK_REMOVE_ARG_NAME'))
|
||||
return parser.parse_args(argv)
|
||||
|
||||
def run(self, argv):
|
||||
args = self.parse_args(argv)
|
||||
name = args.name
|
||||
|
||||
project = ProjectHelper.get_current_project()
|
||||
ProjectHelper.remove_framework(project, name)
|
@@ -0,0 +1,31 @@
|
||||
|
||||
import cocos
|
||||
from MultiLanguage import MultiLanguage
|
||||
|
||||
from package.helper import ProjectHelper
|
||||
|
||||
|
||||
class FrameworkSet(cocos.CCPlugin):
|
||||
@staticmethod
|
||||
def plugin_name():
|
||||
return "set-framework"
|
||||
|
||||
@staticmethod
|
||||
def brief_description():
|
||||
return MultiLanguage.get_string('FRAMEWORK_SET_BRIEF')
|
||||
|
||||
# parse arguments
|
||||
def parse_args(self, argv):
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser(prog="cocos %s" % self.__class__.plugin_name(),
|
||||
description=self.__class__.brief_description())
|
||||
parser.add_argument("name", metavar="NAME", help=MultiLanguage.get_string('FRAMEWORK_SET_ARG_NAME'))
|
||||
return parser.parse_args(argv)
|
||||
|
||||
def run(self, argv):
|
||||
args = self.parse_args(argv)
|
||||
name = args.name
|
||||
|
||||
project = ProjectHelper.get_current_project()
|
||||
ProjectHelper.set_framework(project, name, "1.0")
|
@@ -0,0 +1,31 @@
|
||||
|
||||
import cocos
|
||||
from MultiLanguage import MultiLanguage
|
||||
|
||||
from package.helper import ProjectHelper
|
||||
|
||||
|
||||
class FrameworkUpdate(cocos.CCPlugin):
|
||||
@staticmethod
|
||||
def plugin_name():
|
||||
return "update-framework"
|
||||
|
||||
@staticmethod
|
||||
def brief_description():
|
||||
return MultiLanguage.get_string('FRAMEWORK_UPDATE_BRIEF')
|
||||
|
||||
# parse arguments
|
||||
def parse_args(self, argv):
|
||||
from argparse import ArgumentParser
|
||||
|
||||
parser = ArgumentParser(prog="cocos %s" % self.__class__.plugin_name(),
|
||||
description=self.__class__.brief_description())
|
||||
parser.add_argument("name", metavar="NAME", help=MultiLanguage.get_string('FRAMEWORK_UPDATE_ARG_NAME'))
|
||||
return parser.parse_args(argv)
|
||||
|
||||
def run(self, argv):
|
||||
args = self.parse_args(argv)
|
||||
name = args.name
|
||||
|
||||
project = ProjectHelper.get_current_project()
|
||||
ProjectHelper.update_framework(project, name)
|
@@ -0,0 +1,62 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# cocos "package" plugin
|
||||
#
|
||||
# Copyright 2014 (C) cocos2d-x.org
|
||||
#
|
||||
# License: MIT
|
||||
# ----------------------------------------------------------------------------
|
||||
'''
|
||||
"framework" plugins
|
||||
'''
|
||||
|
||||
__docformat__ = 'restructuredtext'
|
||||
|
||||
import cocos
|
||||
from MultiLanguage import MultiLanguage
|
||||
|
||||
|
||||
class CCPluginFramework(cocos.CCPlugin):
|
||||
@staticmethod
|
||||
def plugin_name():
|
||||
return "framework"
|
||||
|
||||
@staticmethod
|
||||
def brief_description():
|
||||
return MultiLanguage.get_string('FRAMEWORK_BRIEF')
|
||||
|
||||
def parse_args(self, argv):
|
||||
if len(argv) < 1:
|
||||
print "usage: cocos framework [-h] COMMAND arg [arg ...]"
|
||||
print MultiLanguage.get_string('FRAMEWORK_ERROR_TOO_FEW_ARGS')
|
||||
return None
|
||||
|
||||
return {"command": argv[0]}
|
||||
|
||||
def run(self, argv, dependencies):
|
||||
args = self.parse_args(argv)
|
||||
if args is None:
|
||||
return
|
||||
|
||||
command = args["command"]
|
||||
|
||||
if command == "add":
|
||||
from framework_add import FrameworkAdd
|
||||
CommandClass = FrameworkAdd
|
||||
elif command == "remove":
|
||||
from framework_remove import FrameworkRemove
|
||||
CommandClass = FrameworkRemove
|
||||
elif command == "update":
|
||||
from framework_update import FrameworkUpdate
|
||||
CommandClass = FrameworkUpdate
|
||||
elif command == "create":
|
||||
from framework_create import FrameworkCreate
|
||||
CommandClass = FrameworkCreate
|
||||
elif command == "set":
|
||||
from framework_set import FrameworkSet
|
||||
CommandClass = FrameworkSet
|
||||
else:
|
||||
message = MultiLanguage.get_string('FRAMEWORK_ERROR_INVALID_CMD_FMT', command)
|
||||
raise cocos.CCPluginError(message, cocos.CCPluginError.ERROR_CMD_NOT_FOUND)
|
||||
|
||||
commandObject = CommandClass()
|
||||
commandObject.run(argv[1:])
|
Reference in New Issue
Block a user