Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add console script entry point #1745

Merged
merged 11 commits into from
Apr 6, 2018
5 changes: 4 additions & 1 deletion Lib/fontbakery/commands/check_specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ def main(specification=None, values=None):
values_[key] = getattr(args, key)

try:
if not args.fonts:
raise ValueValidationError, "No files to check specified."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I dislike this for two reasons:

  1. now a spec has to have a font's argument, check-specification was clean of that before and specifications could define their dependencies much more freely.
  2. There's a mechanism that raises exactly this error and ends the script (with this PR also with sys.exit(1) So why do it two times?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in #1777


runner = runner_factory(specification
, explicit_checks=args.checkid
, custom_order=args.order
Expand All @@ -200,7 +203,7 @@ def main(specification=None, values=None):
except ValueValidationError as e:
print(e)
argument_parser.print_usage()
sys.exit()
sys.exit(1)

# the most verbose loglevel wins
loglevel = min(args.loglevels) if args.loglevels else DEFAULT_LOG_LEVEL
Expand Down
12 changes: 9 additions & 3 deletions Lib/fontbakery/fonts_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ def __call__(self, parser, namespace, values, option_string=None):
target = [item for l in values for item in l]
setattr(namespace, self.dest, target)

argument_parser.add_argument('fonts', nargs='*', type=get_fonts,
action=MergeAction, help='font file path(s) to check.'
' Wildcards like *.ttf are allowed.')
argument_parser.add_argument(
'fonts',
# To allow optional commands like "-L" to work without other input
# files:
nargs='*',
type=get_fonts,
action=MergeAction,
help='font file path(s) to check. Wildcards like *.ttf are allowed.')

return ('fonts', )

fonts_expected_value = ExpectedValue(
Expand Down
5 changes: 4 additions & 1 deletion Lib/fontbakery/specifications/ufo_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ def __call__(self, parser, namespace, values, option_string=None):

argument_parser.add_argument(
'fonts',
nargs='+',
# To allow optional commands like "-L" to work without other input
# files:
nargs='*',
type=get_fonts,
action=MergeAction,
help='font file path(s) to check.'
' Wildcards like *.ufo are allowed.')

return ('fonts',)


Expand Down