forked from github.com/blag
added --verbose option
this one increases the loglevel to 'debug'
This commit is contained in:
committed by
Bastian Venthur
parent
6005369108
commit
138a78357a
@@ -3,6 +3,7 @@
|
||||
## [unreleased] - XXXX-XX-XX
|
||||
|
||||
* Added --version option
|
||||
* added --verbose option, that increases the loglevel to 'debug'
|
||||
* Improved quickstart:
|
||||
* respective default answers will be written to config if user provided no
|
||||
answer
|
||||
|
||||
13
blag/blag.py
13
blag/blag.py
@@ -39,6 +39,10 @@ def main(args=None):
|
||||
|
||||
"""
|
||||
args = parse_args(args)
|
||||
# set loglevel
|
||||
if args.verbose:
|
||||
logger.setLevel(logging.DEBUG)
|
||||
logger.debug(f"This is blag {__VERSION__}.")
|
||||
args.func(args)
|
||||
|
||||
|
||||
@@ -61,6 +65,11 @@ def parse_args(args=None):
|
||||
action='version',
|
||||
version='%(prog)s '+__VERSION__,
|
||||
)
|
||||
parser.add_argument(
|
||||
'-v', '--verbose',
|
||||
action='store_true',
|
||||
help='Verbose output.',
|
||||
)
|
||||
|
||||
commands = parser.add_subparsers(dest='command')
|
||||
commands.required = True
|
||||
@@ -219,6 +228,7 @@ def build(args):
|
||||
os.makedirs(f'{args.output_dir}/{path}', exist_ok=True)
|
||||
|
||||
# copy static files over
|
||||
logger.info('Copying static files.')
|
||||
if os.path.exists(args.static_dir):
|
||||
shutil.copytree(args.static_dir, args.output_dir, dirs_exist_ok=True)
|
||||
|
||||
@@ -281,7 +291,8 @@ def process_markdown(convertibles, input_dir, output_dir,
|
||||
articles = []
|
||||
pages = []
|
||||
for src, dst in convertibles:
|
||||
logger.info(f'Processing {src}')
|
||||
logger.debug(f'Processing {src}')
|
||||
|
||||
with open(f'{input_dir}/{src}', 'r') as fh:
|
||||
body = fh.read()
|
||||
|
||||
|
||||
@@ -287,3 +287,11 @@ def test_cli_version(capsys):
|
||||
# proper version reported
|
||||
out, _ = capsys.readouterr()
|
||||
assert blag.__VERSION__ in out
|
||||
|
||||
|
||||
def test_cli_verbose(cleandir, caplog):
|
||||
blag.main(['build'])
|
||||
assert 'DEBUG' not in caplog.text
|
||||
|
||||
blag.main(['--verbose', 'build'])
|
||||
assert 'DEBUG' in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user