diff options
Diffstat (limited to 'gerbonara/cli.py')
-rw-r--r-- | gerbonara/cli.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gerbonara/cli.py b/gerbonara/cli.py index 93b989e..5b67da8 100644 --- a/gerbonara/cli.py +++ b/gerbonara/cli.py @@ -23,8 +23,10 @@ import dataclasses import re import warnings import json +import sys import itertools import webbrowser +import warnings from pathlib import Path from .utils import MM, Inch @@ -37,6 +39,18 @@ from .cad.kicad import tmtheme from .cad import protoserve +def _showwarning(message, category, filename, lineno, file=None, line=None): + if file is None: + file = sys.stderr + + filename = Path(filename) + gerbonara_module_install_location = Path(__file__).parent.parent + if filename.is_relative_to(gerbonara_module_install_location): + filename = filename.relative_to(gerbonara_module_install_location) + + print(f'{filename}:{lineno}: {message}', file=file) +warnings.showwarning = _showwarning + def _print_version(ctx, param, value): if value and not ctx.resilient_parsing: click.echo(f'Version {__version__}') @@ -431,7 +445,7 @@ def merge(inpath, outpath, offset, rotation, input_map, command_line_units, outp @click.option('--version', is_flag=True, callback=_print_version, expose_value=False, is_eager=True) @click.option('--warnings', 'format_warnings', type=click.Choice(['default', 'ignore', 'once']), default='default', help='''Enable or disable file format warnings during parsing (default: on)''') -@click.option('--units', type=Unit(), help='Output bounding box in this unit (default: millimeter)') +@click.option('--units', type=Unit(), default='metric', help='Output bounding box in this unit (default: millimeter)') @click.option('--input-number-format', help='Override number format of input file (mostly useful for Excellon files)') @click.option('--input-units', type=Unit(), help='Override units of input file') @click.option('--input-zero-suppression', type=click.Choice(['off', 'leading', 'trailing']), help='Override zero suppression setting of input file') |