Skip to content

Commit

Permalink
✨ add -d for development tracing. fix #185
Browse files Browse the repository at this point in the history
  • Loading branch information
chfw committed Aug 16, 2019
1 parent ec7c611 commit a6d04e0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions moban/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
LABEL_DEST = "destination"
LABEL_FORCE_TEMPLATE_TYPE = "force_template_type"
LABEL_TEMPLATE_TYPES = "template_types"
LABEL_DEBUG = "debug"

# error messages
ERROR_DATA_FILE_NOT_FOUND = "Both %s and %s does not exist"
Expand Down
14 changes: 14 additions & 0 deletions moban/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import sys
import logging
import argparse
import logging.config

from moban import plugins, reporter, constants, mobanfile, exceptions
from moban.utils import merge
Expand All @@ -28,6 +29,12 @@ def main():
parser = create_parser()
options = vars(parser.parse_args())
HASH_STORE.IGNORE_CACHE_FILE = options[constants.LABEL_FORCE]
if options[constants.LABEL_DEBUG]:
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.DEBUG,
)

moban_file = options[constants.LABEL_MOBANFILE]
load_engine_factory_and_engines() # Error: jinja2 if removed
if moban_file is None:
Expand Down Expand Up @@ -126,6 +133,13 @@ def create_parser():
action="version",
version="%(prog)s {v}".format(v=__version__),
)
parser.add_argument(
"-d",
action="store_true",
dest=constants.LABEL_DEBUG,
default=False,
help="to show debug trace",
)
return parser


Expand Down
1 change: 1 addition & 0 deletions moban/mobanfile/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

def handle_template(template_file, output, template_dirs):
log.info("handling %s" % template_file)

template_file = file_system.to_unicode(template_file)
multi_fs = file_system.get_multi_fs(template_dirs)
if template_file.endswith("**"):
Expand Down

0 comments on commit a6d04e0

Please sign in to comment.