Skip to content

Commit ad0fcb1

Browse files
author
Bin Zhang
authored
Merge pull request #406 from natural-law/skip-agreement
Add argument "--agreement" for skip the shown of agreement.
2 parents b9128c5 + 4af08d1 commit ad0fcb1

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

bin/cocos.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# FIXME: MultiLanguage should be deprecated in favor of gettext
3333
from MultiLanguage import MultiLanguage
3434

35-
COCOS2D_CONSOLE_VERSION = '2.2'
35+
COCOS2D_CONSOLE_VERSION = '2.3'
3636

3737

3838
class Cocos2dIniParser:
@@ -337,13 +337,17 @@ def change_agree_stat(cls, agreed):
337337
f.close()
338338

339339
@classmethod
340-
def show_stat_agreement(cls):
340+
def show_stat_agreement(cls, skip_agree_value=None):
341341
if cls.is_agreement_shown():
342342
return
343343

344-
# show the agreement
345-
input_value = raw_input(MultiLanguage.get_string('COCOS_AGREEMENT'))
346-
agreed = (input_value.lower() != 'n' and input_value.lower() != 'no')
344+
if skip_agree_value is None:
345+
# show the agreement
346+
input_value = raw_input(MultiLanguage.get_string('COCOS_AGREEMENT'))
347+
agreed = (input_value.lower() != 'n' and input_value.lower() != 'no')
348+
else:
349+
# --agreement is used to skip the input
350+
agreed = skip_agree_value
347351
cls.change_agree_stat(agreed)
348352

349353
# change the last time statistics status in local config file.
@@ -963,6 +967,25 @@ def _check_python_version():
963967
sys.argv.pop(idx)
964968
sys.argv.pop(idx)
965969

970+
agreement_arg = '--agreement'
971+
skip_agree_value = None
972+
if agreement_arg in sys.argv:
973+
idx = sys.argv.index(agreement_arg)
974+
if idx == (len(sys.argv) - 1):
975+
Logging.error(MultiLanguage.get_string('COCOS_ERROR_AGREEMENT_NO_VALUE'))
976+
sys.exit(CCPluginError.ERROR_WRONG_ARGS)
977+
978+
# get the argument value
979+
agree_value = sys.argv[idx+1]
980+
if agree_value.lower() == 'n':
981+
skip_agree_value = False
982+
else:
983+
skip_agree_value = True
984+
985+
# remove the argument '--agreement' & the value
986+
sys.argv.pop(idx)
987+
sys.argv.pop(idx)
988+
966989
# Get the engine version for the DataStat
967990
cur_path = get_current_path()
968991
engine_path = os.path.normpath(os.path.join(cur_path, '../../../'))
@@ -973,7 +996,7 @@ def _check_python_version():
973996
if match:
974997
STAT_VERSION = match.group(1)
975998

976-
DataStatistic.show_stat_agreement()
999+
DataStatistic.show_stat_agreement(skip_agree_value)
9771000
DataStatistic.stat_event('cocos', 'start', 'invoked')
9781001

9791002
if not _check_python_version():

bin/strings.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
"COCOS_PARSE_PLUGIN_WARNING_FMT" : "Warning: plugin '%s' does not return a plugin name.",
55
"COCOS_HELP_BRIEF_FMT" : "\n%s %s - cocos console: A command line tool for Cocos2d-x.",
66
"COCOS_HELP_AVAILABLE_CMD" : "\nAvailable commands:",
7-
"COCOS_HELP_AVAILABLE_ARGS_FMT" : "\nAvailable arguments:\n\t-h, --help\t\t\tShow this help information.\n\t-v, --version\t\t\tShow the version of this command tool.\n\t--ol %s\tSpecify the language of output messages.",
7+
"COCOS_HELP_AVAILABLE_ARGS_FMT" : "\nAvailable arguments:\n\t-h, --help\t\t\tShow this help information.\n\t-v, --version\t\t\tShow the version of this command tool.\n\t--ol %s\tSpecify the language of output messages.\n\t--agreement ['y', 'n']\t\tSkip the agreement with specified value.",
88
"COCOS_HELP_EXAMPLE" : "\nExample:\n\tcocos new --help\n\tcocos run --help",
99
"COCOS_HELP_ARG_SRC" : "Specify the path of the project.",
1010
"COCOS_HELP_ARG_QUIET" : "Less output",
1111
"COCOS_HELP_ARG_PLATFORM" : "Specify the target platform.",
1212
"COCOS_HELP_ARG_PROJ_DIR" : "Specify the directory for target platform.",
1313
"COCOS_ERROR_OL_NO_VALUE" : "Please specify the value of argument '--ol'.",
14+
"COCOS_ERROR_AGREEMENT_NO_VALUE" : "Please specify the value of argument '--agreement'.",
1415
"COCOS_WARNING_LANG_NOT_SUPPORT_FMT" : "Language '%s' is not support now.",
1516
"COCOS_PYTHON_VERSION_TIP_FMT" : "The Python version is %d.%d. But Python 2.7 is required.\nDownload it here: https://www.python.org/",
1617
"COCOS_WARNING_INVALID_DIR_IN_INI_FMT" : "Warning: Invalid directory defined in cocos2d.ini: %s",
@@ -346,13 +347,14 @@
346347
"COCOS_PARSE_PLUGIN_WARNING_FMT" : "警告:'%s' 不是可用的命令。",
347348
"COCOS_HELP_BRIEF_FMT" : "\n%s %s - cocos console: cocos2d-x 的命令行工具集。",
348349
"COCOS_HELP_AVAILABLE_CMD" : "\n可用的命令:",
349-
"COCOS_HELP_AVAILABLE_ARGS_FMT" : "\n可用的参数:\n\t-h, --help\t\t\t显示帮助信息。\n\t-v, --version\t\t\t显示命令行工具的版本号。\n\t--ol %s\t指定输出信息的语言。",
350+
"COCOS_HELP_AVAILABLE_ARGS_FMT" : "\n可用的参数:\n\t-h, --help\t\t\t显示帮助信息。\n\t-v, --version\t\t\t显示命令行工具的版本号。\n\t--ol %s\t指定输出信息的语言。\n\t--agreement ['y', 'n']\t\t使用指定的值来同意或拒绝协议。",
350351
"COCOS_HELP_EXAMPLE" : "\n示例:\n\tcocos new --help\n\tcocos run --help",
351352
"COCOS_HELP_ARG_SRC" : "指定工程路径。",
352353
"COCOS_HELP_ARG_QUIET" : "较少的输出。",
353354
"COCOS_HELP_ARG_PLATFORM" : "指定目标平台。",
354355
"COCOS_HELP_ARG_PROJ_DIR" : "指定目标平台路径。",
355356
"COCOS_ERROR_OL_NO_VALUE" : "参数 '--ol' 未指定值。",
357+
"COCOS_ERROR_AGREEMENT_NO_VALUE" : "参数 '--agreement' 未指定值。",
356358
"COCOS_WARNING_LANG_NOT_SUPPORT_FMT" : "目前不支持 '%s' 语言。",
357359
"COCOS_PYTHON_VERSION_TIP_FMT" : "当前 python 版本为:%d.%d。要求使用 Python 2.7。\n下载地址:https://www.python.org/",
358360
"COCOS_WARNING_INVALID_DIR_IN_INI_FMT" : "警告:cocos2d.ini 中使用了无效的路径 %s",
@@ -688,12 +690,13 @@
688690
"COCOS_PARSE_PLUGIN_WARNING_FMT" : "警告:'%s' 不是可用的命令。",
689691
"COCOS_HELP_BRIEF_FMT" : "\n%s %s - cocos console: cocos2d-x 的命令行工具集。",
690692
"COCOS_HELP_AVAILABLE_CMD" : "\n可用的命令:",
691-
"COCOS_HELP_AVAILABLE_ARGS_FMT" : "\n可用的參數:\n\t-h, --help\t\t\t顯示幫助資訊。\n\t-v, --version\t\t\t顯示命令行工具的版本號。\n\t--ol %s\t指定輸出資訊的語言。",
693+
"COCOS_HELP_AVAILABLE_ARGS_FMT" : "\n可用的參數:\n\t-h, --help\t\t\t顯示幫助資訊。\n\t-v, --version\t\t\t顯示命令行工具的版本號。\n\t--ol %s\t指定輸出資訊的語言。\n\t--agreement ['y', 'n']\t\t使用指定的值來同意或拒絕協議。",
692694
"COCOS_HELP_EXAMPLE" : "\n示例:\n\tcocos new --help\n\tcocos run --help",
693695
"COCOS_HELP_ARG_SRC" : "指定工程路徑。",
694696
"COCOS_HELP_ARG_QUIET" : "較少的輸出。",
695697
"COCOS_HELP_ARG_PLATFORM" : "指定目標平臺。",
696698
"COCOS_ERROR_OL_NO_VALUE" : "參數 '--ol' 未指定值。",
699+
"COCOS_ERROR_AGREEMENT_NO_VALUE" : "參數 '--agreement' 未指定值。",
697700
"COCOS_WARNING_LANG_NOT_SUPPORT_FMT" : "目前不支持 '%s' 語言。",
698701
"COCOS_PYTHON_VERSION_TIP_FMT" : "當前 python 版本為:%d.%d。要求使用 Python 2.7。\n下載地址:https://www.python.org/",
699702
"COCOS_WARNING_INVALID_DIR_IN_INI_FMT" : "警告:cocos2d.ini 中使用了無效的路徑 %s",

0 commit comments

Comments
 (0)