24
24
import string
25
25
import locale
26
26
import gettext
27
+ import json
28
+
27
29
28
30
# FIXME: MultiLanguage should be deprecated in favor of gettext
29
31
from MultiLanguage import MultiLanguage
30
32
31
- COCOS2D_CONSOLE_VERSION = '2.0 '
33
+ COCOS2D_CONSOLE_VERSION = '2.1 '
32
34
33
35
34
36
class Cocos2dIniParser :
@@ -257,8 +259,6 @@ class DataStatistic(object):
257
259
# change the last time statistics status in local config file.
258
260
@classmethod
259
261
def change_last_state (cls , cfg_file , enabled ):
260
- import json
261
-
262
262
# get current local config info
263
263
if not os .path .isfile (cfg_file ):
264
264
cur_info = {}
@@ -281,8 +281,6 @@ def change_last_state(cls, cfg_file, enabled):
281
281
# get the last time statistics status in local config file.
282
282
@classmethod
283
283
def get_last_state (cls , cfg_file ):
284
- import json
285
-
286
284
# get the config
287
285
if not os .path .isfile (cfg_file ):
288
286
cur_info = None
@@ -532,6 +530,8 @@ def _check_custom_options(self, args):
532
530
def parse_args (self , argv ):
533
531
from argparse import ArgumentParser
534
532
533
+ # FIXME:
534
+ # CCPlugin should not parse any argument. Plugins are responsoble for doing it
535
535
parser = ArgumentParser (prog = "cocos %s" % self .__class__ .plugin_name (),
536
536
description = self .__class__ .brief_description ())
537
537
parser .add_argument ("-s" , "--src" ,
@@ -545,6 +545,10 @@ def parse_args(self, argv):
545
545
parser .add_argument ("-p" , "--platform" ,
546
546
dest = "platform" ,
547
547
help = MultiLanguage .get_string ('COCOS_HELP_ARG_PLATFORM' ))
548
+ parser .add_argument ("--list-platforms" ,
549
+ action = "store_true" ,
550
+ dest = "listplatforms" ,
551
+ help = _ ("List available platforms" ))
548
552
parser .add_argument ("--proj-dir" ,
549
553
dest = "proj_dir" ,
550
554
help = MultiLanguage .get_string ('COCOS_HELP_ARG_PROJ_DIR' ))
@@ -569,6 +573,12 @@ def parse_args(self, argv):
569
573
raise CCPluginError (MultiLanguage .get_string ('COCOS_ERROR_UNKNOWN_PLATFORM_FMT' , args .platform ),
570
574
CCPluginError .ERROR_WRONG_ARGS )
571
575
576
+ if args .listplatforms and self ._project is not None :
577
+ platforms = cocos_project .Platforms (self ._project , args .platform , args .proj_dir )
578
+ p = platforms .get_available_platforms ().keys ()
579
+ print ('{"platforms":' + json .dumps (p ) + '}' )
580
+ sys .exit (0 )
581
+
572
582
self .init (args )
573
583
self ._check_custom_options (args )
574
584
0 commit comments