diff options
-rwxr-xr-x | .ci/local/test.sh | 2 | ||||
-rw-r--r-- | cgitize/main.py | 8 | ||||
-rw-r--r-- | cgitize/utils.py | 5 |
3 files changed, 9 insertions, 6 deletions
diff --git a/.ci/local/test.sh b/.ci/local/test.sh index 99728e4..8ae7fe9 100755 --- a/.ci/local/test.sh +++ b/.ci/local/test.sh @@ -127,7 +127,7 @@ cgitize() { echo Running cgitize echo ---------------------------------------------------------------------- - python3 -m cgitize.main --config "$cgitize_conf_path" + python3 -m cgitize.main --config "$cgitize_conf_path" --verbose } check_contains() { diff --git a/cgitize/main.py b/cgitize/main.py index dd6b41e..60a5e70 100644 --- a/cgitize/main.py +++ b/cgitize/main.py @@ -16,18 +16,20 @@ def parse_args(argv=None): if argv is None: argv = sys.argv[1:] parser = ArgumentParser() - parser.add_argument('--config', metavar='PATH', + parser.add_argument('--config', '-c', metavar='PATH', default=Config.DEFAULT_PATH, help='config file path') parser.add_argument('--repo', metavar='REPO_ID', nargs='*', dest='repos', help='repos to pull') + parser.add_argument('--verbose', '-v', action='store_true', + help='verbose log output') return parser.parse_args(argv) def main(args=None): - with setup_logging(): - args = parse_args(args) + args = parse_args() + with setup_logging(args.verbose): config = Config.read(args.config) my_repos = config.import_my_repos() cgit_server = CGitServer(config.clone_url) diff --git a/cgitize/utils.py b/cgitize/utils.py index 152684f..2f91939 100644 --- a/cgitize/utils.py +++ b/cgitize/utils.py @@ -12,9 +12,10 @@ import sys @contextmanager -def setup_logging(): +def setup_logging(verbose=False): + level = logging.DEBUG if verbose else logging.INFO logging.basicConfig( - level=logging.DEBUG, + level=level, datefmt='%Y-%m-%d %H:%M:%S', format='%(asctime)s | %(levelname)s | %(message)s', # Log to stdout, because that's where subprocess's output goes (so that |