2828 CompiledComponentsPythonRecipe ,
2929 BootstrapNDKRecipe , NDKRecipe )
3030from pythonforandroid .archs import (ArchARM , ArchARMv7_a , Archx86 )
31- from pythonforandroid .logger import (logger , info , warning , debug ,
31+ from pythonforandroid .logger import (logger , info , warning , setup_color ,
3232 Out_Style , Out_Fore , Err_Style , Err_Fore ,
33- info_notify , info_main , shprint ,
34- Null_Fore , Null_Style )
33+ info_notify , info_main , shprint )
3534from pythonforandroid .util import current_directory , ensure_dir
3635from pythonforandroid .bootstrap import Bootstrap
3736from pythonforandroid .distribution import Distribution , pretty_log_dists
4342sys .path .insert (0 , join (toolchain_dir , "tools" , "external" ))
4443
4544
46- info ('' .join (
47- [Err_Style .BRIGHT , Err_Fore .RED ,
48- 'This python-for-android revamp is an experimental alpha release!' ,
49- Err_Style .RESET_ALL ]))
50- info ('' .join (
51- [Err_Fore .RED ,
52- ('It should work (mostly), but you may experience '
53- 'missing features or bugs.' ),
54- Err_Style .RESET_ALL ]))
55-
56-
5745def add_boolean_option (parser , names , no_names = None ,
5846 default = True , dest = None , description = None ):
5947 group = parser .add_argument_group (description = description )
@@ -204,6 +192,9 @@ def __init__(self):
204192 parser .add_argument (
205193 '--debug' , dest = 'debug' , action = 'store_true' ,
206194 help = 'Display debug output and all build info' )
195+ parser .add_argument (
196+ '--color' , dest = 'color' , choices = ['always' , 'never' , 'auto' ],
197+ help = 'Enable or disable color output (default enabled on tty)' )
207198 parser .add_argument (
208199 '--sdk-dir' , '--sdk_dir' , dest = 'sdk_dir' , default = '' ,
209200 help = 'The filepath where the Android SDK is installed' )
@@ -282,6 +273,18 @@ def __init__(self):
282273 args , unknown = parser .parse_known_args (sys .argv [1 :])
283274 self .dist_args = args
284275
276+ setup_color (args .color )
277+
278+ info ('' .join (
279+ [Err_Style .BRIGHT , Err_Fore .RED ,
280+ 'This python-for-android revamp is an experimental alpha release!' ,
281+ Err_Style .RESET_ALL ]))
282+ info ('' .join (
283+ [Err_Fore .RED ,
284+ ('It should work (mostly), but you may experience '
285+ 'missing features or bugs.' ),
286+ Err_Style .RESET_ALL ]))
287+
285288 # strip version from requirements, and put them in environ
286289 requirements = []
287290 for requirement in split_argument_list (args .requirements ):
@@ -357,19 +360,8 @@ def recipes(self, args):
357360 "--compact" , action = "store_true" , default = False ,
358361 help = "Produce a compact list suitable for scripting" )
359362
360- add_boolean_option (
361- parser , ["color" ],
362- default = True ,
363- description = 'Whether the output should be colored:' )
364-
365363 args = parser .parse_args (args )
366364
367- Fore = Out_Fore
368- Style = Out_Style
369- if not args .color :
370- Fore = Null_Fore
371- Style = Null_Style
372-
373365 ctx = self .ctx
374366 if args .compact :
375367 print (" " .join (set (Recipe .list_recipes (ctx ))))
@@ -380,18 +372,18 @@ def recipes(self, args):
380372 print ('{Fore.BLUE}{Style.BRIGHT}{recipe.name:<12} '
381373 '{Style.RESET_ALL}{Fore.LIGHTBLUE_EX}'
382374 '{version:<8}{Style.RESET_ALL}' .format (
383- recipe = recipe , Fore = Fore , Style = Style ,
375+ recipe = recipe , Fore = Out_Fore , Style = Out_Style ,
384376 version = version ))
385377 print (' {Fore.GREEN}depends: {recipe.depends}'
386- '{Fore.RESET}' .format (recipe = recipe , Fore = Fore ))
378+ '{Fore.RESET}' .format (recipe = recipe , Fore = Out_Fore ))
387379 if recipe .conflicts :
388380 print (' {Fore.RED}conflicts: {recipe.conflicts}'
389381 '{Fore.RESET}'
390- .format (recipe = recipe , Fore = Fore ))
382+ .format (recipe = recipe , Fore = Out_Fore ))
391383 if recipe .opt_depends :
392384 print (' {Fore.YELLOW}optional depends: '
393385 '{recipe.opt_depends}{Fore.RESET}'
394- .format (recipe = recipe , Fore = Fore ))
386+ .format (recipe = recipe , Fore = Out_Fore ))
395387
396388 def bootstraps (self , args ):
397389 '''List all the bootstraps available to build with.'''
0 commit comments