@@ -17,6 +17,7 @@ from babel.dates import tokenize_pattern, PATTERN_CHARS
1717from babel .localedata import load , normalize_locale , LocaleDataDict
1818
1919from cleo import Application , Command
20+ from cleo import argument
2021from pendulum import __version__
2122
2223
@@ -43,12 +44,11 @@ class _LambdaCompiler(_GettextCompiler):
4344
4445
4546class LocaleCreate (Command ):
46- """
47- Creates locale translations.
4847
49- locale:create
50- {locales?* : Locales to dump}
51- """
48+ name = "create"
49+ description = "Creates locale translations."
50+
51+ arguments = [argument ("locales" , "Locales to dump." , optional = False , multiple = True )]
5252
5353 TEMPLATE = """# -*- coding: utf-8 -*-
5454from __future__ import unicode_literals
@@ -93,7 +93,7 @@ translations = {{}}
9393
9494 normalized = normalize_locale (locale .replace ("-" , "_" ))
9595 if not normalized :
96- self .error ( " Locale [{}] does not exist." .format (locale ))
96+ self .line ( "<error> Locale [{}] does not exist.</error> " .format (locale ))
9797 continue
9898
9999 self .line ("<info>Generating <comment>{}</> locale.</>" .format (locale ))
@@ -229,11 +229,9 @@ translations = {{}}
229229
230230
231231class LocaleRecreate (Command ):
232- """
233- Recreate existing locales.
234232
235- locale: recreate
236- "" "
233+ name = " recreate"
234+ description = "Recreate existing locales. "
237235
238236 def handle (self ):
239237 # Listing locales
@@ -245,12 +243,21 @@ class LocaleRecreate(Command):
245243 self .call ("locale:create" , [("locales" , locales )])
246244
247245
246+ class LocaleCommand (Command ):
247+
248+ name = "locale"
249+ description = "Locale related commands."
250+
251+ commands = [LocaleCreate ()]
252+
253+ def handle (self ):
254+ self .call ("help" , self ._config .name )
255+
256+
248257class WindowsTzDump (Command ):
249- """
250- Dumps the mapping of Windows timezones to IANA timezones.
251258
252- windows:tz: dump
253- "" "
259+ name = " dump-timezones"
260+ description = "Dumps the mapping of Windows timezones to IANA timezones. "
254261
255262 MAPPING_DIR = os .path .join ("pendulum" , "tz" , "data" )
256263
@@ -269,10 +276,20 @@ class WindowsTzDump(Command):
269276 f .write (mapping )
270277
271278
272- app = Application ("Clock" , __version__ )
273- app .add (LocaleCreate ())
274- app .add (LocaleRecreate ())
275- app .add (WindowsTzDump ())
279+ class WindowsCommand (Command ):
280+
281+ name = "windows"
282+ description = "Windows related commands."
283+
284+ commands = [WindowsTzDump ()]
285+
286+ def handle (self ):
287+ self .call ("help" , self ._config .name )
288+
289+
290+ app = Application ("clock" , __version__ )
291+ app .add (LocaleCommand ())
292+ app .add (WindowsCommand ())
276293
277294
278295if __name__ == "__main__" :
0 commit comments