From c647a2cbdb3aeaa6bd8c4c4293e0587130da80f5 Mon Sep 17 00:00:00 2001 From: David THENON Date: Sat, 21 Dec 2013 11:07:12 +0100 Subject: [PATCH] Add shortcut argument for some command options --- optimus/cli/build.py | 4 ++-- optimus/cli/po.py | 22 +++++++++++++++------- optimus/cli/runserver.py | 4 ++-- optimus/cli/watch.py | 4 ++-- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/optimus/cli/build.py b/optimus/cli/build.py index 81daf0e..5562c47 100644 --- a/optimus/cli/build.py +++ b/optimus/cli/build.py @@ -8,8 +8,8 @@ from optimus.logs import init_logging -@arg('--settings', default='settings', help="Python path to the settings module") -@arg('--loglevel', default='info', choices=['debug','info','warning','error','critical'], help="The minimal verbosity level to limit logs output") +@arg('-s', '--settings', default='settings', help="Python path to the settings module") +@arg('-l', '--loglevel', default='info', choices=['debug','info','warning','error','critical'], help="The minimal verbosity level to limit logs output") @arg('--logfile', default=None, help="A filepath that if setted, will be used to save logs output") #@arg('--dry-run', default=False, help="Parse page templates, scan them to search their dependancies but don't build them") def build(args): diff --git a/optimus/cli/po.py b/optimus/cli/po.py index 9c50a2b..e073ff7 100644 --- a/optimus/cli/po.py +++ b/optimus/cli/po.py @@ -2,18 +2,19 @@ """ Command line action to manage translation PO files with pybabel """ -import datetime, glob, os, tempfile +import datetime, os from argh import arg from optimus.logs import init_logging from optimus.i18n import I18NManager -@arg('--init', default=False, help="Initialize structure, create template catalog (POT) and initialize catalogs (PO)") -@arg('--update', default=False, help="Extract translations, update the template catalog (POT) and update the catalogs (PO)") -@arg('--compile', default=False, help="Process to compilation of catalogs") -@arg('--settings', default='settings', help="Python path to the settings module") -@arg('--loglevel', default='info', choices=['debug','info','warning','error','critical'], help="The minimal verbosity level to limit logs output") +@arg('-i', '--init', default=False, help="Initialize structure, create template catalog (POT) and initialize catalogs (PO)") +@arg('-u', '--update', default=False, help="Extract translations, update the template catalog (POT) and update the catalogs (PO)") +@arg('-c', '--compile', default=False, help="Process to compilation of catalogs") +@arg('-b', '--backup', default=False, help="Make a backup of the locale directory before doing anything") +@arg('-s', '--settings', default='settings', help="Python path to the settings module") +@arg('-l', '--loglevel', default='info', choices=['debug','info','warning','error','critical'], help="The minimal verbosity level to limit logs output") @arg('--logfile', default=None, help="A filepath that if setted, will be used to save logs output") def po(args, init=False, update=False, compile=False): """ @@ -32,7 +33,14 @@ def po(args, init=False, update=False, compile=False): i18n = I18NManager(root_logger, settings) - # TODO: Should we do this automatically to prevent error on missing files + # TODO: * Copy the actual locale directory to a temporary directory + # * If process is success, remove previous backup dir if exists then promote the temp backup dir as the current backup + # * If process goes wrong, just remove the temp backup dir + # -> Always keeping only one backup dir and allways for a successful process + if args.backup: + pass + + # NOTE: Should we do this automatically to prevent error on missing files # OR should we only do checking before and abort on the first missing file ? if args.init or args.update or args.compile: i18n.init_locales_dir() diff --git a/optimus/cli/runserver.py b/optimus/cli/runserver.py index ed37d55..f46a140 100644 --- a/optimus/cli/runserver.py +++ b/optimus/cli/runserver.py @@ -14,8 +14,8 @@ import cherrypy @arg('hostname', help="Hostname to bind the server to, use PORT or ADDRESS:PORT") -@arg('--settings', default='settings', help='Python path to the settings module') -@arg('--loglevel', default='info', choices=['debug','info','warning','error','critical'], help='The minimal verbosity level to limit logs output') +@arg('-s', '--settings', default='settings', help='Python path to the settings module') +@arg('-l', '--loglevel', default='info', choices=['debug','info','warning','error','critical'], help='The minimal verbosity level to limit logs output') @arg('--logfile', default=None, help='A filepath that if setted, will be used to save logs output') @arg('--silent', default=False, help="If setted, logs output won't be printed out") def runserver(args): diff --git a/optimus/cli/watch.py b/optimus/cli/watch.py index aba7475..79ad6d2 100644 --- a/optimus/cli/watch.py +++ b/optimus/cli/watch.py @@ -10,8 +10,8 @@ from optimus.logs import init_logging -@arg('--settings', default='settings', help='Python path to the settings module') -@arg('--loglevel', default='info', choices=['debug','info','warning','error','critical'], help='The minimal verbosity level to limit logs output') +@arg('-s', '--settings', default='settings', help='Python path to the settings module') +@arg('-l', '--loglevel', default='info', choices=['debug','info','warning','error','critical'], help='The minimal verbosity level to limit logs output') @arg('--logfile', default=None, help='A filepath that if setted, will be used to save logs output') @arg('--silent', default=False, help="If setted, logs output won't be printed out") def watch(args):