mirror of
https://github.com/venthur/blag.git
synced 2025-11-25 20:52:43 +00:00
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
|
## [unreleased] - XXXX-XX-XX
|
||||||
|
|
||||||
* Added --version option
|
* Added --version option
|
||||||
|
* added --verbose option, that increases the loglevel to 'debug'
|
||||||
* Improved quickstart:
|
* Improved quickstart:
|
||||||
* respective default answers will be written to config if user provided no
|
* respective default answers will be written to config if user provided no
|
||||||
answer
|
answer
|
||||||
|
|||||||
13
blag/blag.py
13
blag/blag.py
@@ -39,6 +39,10 @@ def main(args=None):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
args = parse_args(args)
|
args = parse_args(args)
|
||||||
|
# set loglevel
|
||||||
|
if args.verbose:
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
logger.debug(f"This is blag {__VERSION__}.")
|
||||||
args.func(args)
|
args.func(args)
|
||||||
|
|
||||||
|
|
||||||
@@ -61,6 +65,11 @@ def parse_args(args=None):
|
|||||||
action='version',
|
action='version',
|
||||||
version='%(prog)s '+__VERSION__,
|
version='%(prog)s '+__VERSION__,
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-v', '--verbose',
|
||||||
|
action='store_true',
|
||||||
|
help='Verbose output.',
|
||||||
|
)
|
||||||
|
|
||||||
commands = parser.add_subparsers(dest='command')
|
commands = parser.add_subparsers(dest='command')
|
||||||
commands.required = True
|
commands.required = True
|
||||||
@@ -219,6 +228,7 @@ def build(args):
|
|||||||
os.makedirs(f'{args.output_dir}/{path}', exist_ok=True)
|
os.makedirs(f'{args.output_dir}/{path}', exist_ok=True)
|
||||||
|
|
||||||
# copy static files over
|
# copy static files over
|
||||||
|
logger.info('Copying static files.')
|
||||||
if os.path.exists(args.static_dir):
|
if os.path.exists(args.static_dir):
|
||||||
shutil.copytree(args.static_dir, args.output_dir, dirs_exist_ok=True)
|
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 = []
|
articles = []
|
||||||
pages = []
|
pages = []
|
||||||
for src, dst in convertibles:
|
for src, dst in convertibles:
|
||||||
logger.info(f'Processing {src}')
|
logger.debug(f'Processing {src}')
|
||||||
|
|
||||||
with open(f'{input_dir}/{src}', 'r') as fh:
|
with open(f'{input_dir}/{src}', 'r') as fh:
|
||||||
body = fh.read()
|
body = fh.read()
|
||||||
|
|
||||||
|
|||||||
@@ -287,3 +287,11 @@ def test_cli_version(capsys):
|
|||||||
# proper version reported
|
# proper version reported
|
||||||
out, _ = capsys.readouterr()
|
out, _ = capsys.readouterr()
|
||||||
assert blag.__VERSION__ in out
|
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