|
|
@ -16,6 +16,9 @@ from songbook_core.build import SongbookBuilder, DEFAULT_STEPS |
|
|
|
from songbook_core import __STR_VERSION__ |
|
|
|
from songbook_core import errors |
|
|
|
|
|
|
|
# Logging configuration |
|
|
|
logging.basicConfig(level=logging.INFO) |
|
|
|
LOGGER = logging.getLogger() |
|
|
|
|
|
|
|
# pylint: disable=too-few-public-methods |
|
|
|
class ParseStepsAction(argparse.Action): |
|
|
@ -32,6 +35,10 @@ class ParseStepsAction(argparse.Action): |
|
|
|
), |
|
|
|
) |
|
|
|
|
|
|
|
class VerboseAction(argparse.Action): |
|
|
|
def __call__(self, *_args, **_kwargs): |
|
|
|
LOGGER.setLevel(logging.DEBUG) |
|
|
|
|
|
|
|
def argument_parser(args): |
|
|
|
"""Parse argumnts""" |
|
|
|
parser = argparse.ArgumentParser(description="A song book compiler") |
|
|
@ -49,6 +56,11 @@ def argument_parser(args): |
|
|
|
subdirectories are 'songs', 'img', 'latex', 'templates'. |
|
|
|
""")) |
|
|
|
|
|
|
|
parser.add_argument('--verbose', '-v', nargs=0, action=VerboseAction, |
|
|
|
help=textwrap.dedent("""\ |
|
|
|
Show details about the compilation process. |
|
|
|
""")) |
|
|
|
|
|
|
|
parser.add_argument('--steps', '-s', nargs=1, type=str, |
|
|
|
action=ParseStepsAction, |
|
|
|
help=textwrap.dedent("""\ |
|
|
@ -74,10 +86,6 @@ def argument_parser(args): |
|
|
|
def main(): |
|
|
|
"""Main function:""" |
|
|
|
|
|
|
|
# Logging configuration |
|
|
|
logging.basicConfig(name='songbook', level=logging.INFO) |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
# set script locale to match user's |
|
|
|
try: |
|
|
|
locale.setlocale(locale.LC_ALL, '') |
|
|
@ -111,7 +119,10 @@ def main(): |
|
|
|
|
|
|
|
sb_builder.build_steps(options.steps) |
|
|
|
except errors.SongbookError as error: |
|
|
|
logger.error(error) |
|
|
|
LOGGER.error(error) |
|
|
|
LOGGER.error( |
|
|
|
"Running again with option '-v' may give more information." |
|
|
|
) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
sys.exit(0) |
|
|
|