@@ -127,27 +127,35 @@ def fetch_lastest_archive() -> bytes:
127127
128128
129129def main ():
130+ def green (txt : str ) -> str :
131+ return '\33 [32m' + txt + '\33 [0m'
132+
133+ def red (txt : str ) -> str :
134+ return '\33 [31m' + txt + '\33 [0m'
135+
130136 if not (len (sys .argv ) == 3 ):
131- print ("Usage: python3 create-android-kotlin-app.py PROJECT_NAME APP_PACKAGE_NAME" )
137+ print ('Usage: python3 create-android-kotlin-app.py ' +
138+ green ('<PROJECT_NAME> <APP_PACKAGE_NAME>' ))
132139 return
133140
134141 project_name = sys .argv [1 ]
135142 if os .path .exists (project_name ):
136- print ('Can not create project. There is already a directory named "%s" in the current path.' % project_name )
143+ print (red ('Error: ' ) + 'Can not create project. ' +
144+ 'There is already a directory named %s in the current path.' % green (project_name ))
137145 return
138146 try :
139147 os .mkdir (project_name )
140148 except :
141- print (' Can not create directory "%s". ' % project_name )
149+ print (red ( 'Error: ' ) + ' Can not create directory %s ' % green ( project_name ) )
142150 return
143151
144152 package_name = sys .argv [2 ]
145153 if not re .match ('^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$' , package_name ):
146- print (' Invaild java package name "%s". ' % package_name )
154+ print (red ( 'Error: ' ) + ' Invaild java package name %s ' % green ( package_name ) )
147155 return
148156
149- print ('Creating a new android kotlin app in "%s". \n ' % project_name )
150- print ('Fetching the lastest source code archive from %s\n This might take a couple minutes.' % REPO_URL )
157+ print ('Creating a new android kotlin app in %s \n ' % green ( "./" + project_name ) )
158+ print ('Fetching the lastest source code archive from %s\n This might take a couple minutes.' % green ( REPO_URL ) )
151159 archive_data = fetch_lastest_archive ()
152160
153161 print ('Unziping template files...\n ' )
0 commit comments