summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo (XenGi) Band <email@ricardo.band>2021-06-04 02:08:13 +0200
committerjaseg <git@jaseg.de>2021-06-06 13:16:17 +0200
commit8bad573131e4c91782425d81a141dd656b622d7b (patch)
tree72e88239c26cac4b6222af7724a7bc4c08f9da4b
parentea1d14b7f3fb80e46c7ad60d69aa223e6c532684 (diff)
downloadgerbonara-8bad573131e4c91782425d81a141dd656b622d7b.tar.gz
gerbonara-8bad573131e4c91782425d81a141dd656b622d7b.tar.bz2
gerbonara-8bad573131e4c91782425d81a141dd656b622d7b.zip
add new pcb-tools cli
-rw-r--r--gerbonara/__init__.py1
-rw-r--r--gerbonara/cli.py39
-rw-r--r--setup.py9
3 files changed, 47 insertions, 2 deletions
diff --git a/gerbonara/__init__.py b/gerbonara/__init__.py
new file mode 100644
index 0000000..b8023d8
--- /dev/null
+++ b/gerbonara/__init__.py
@@ -0,0 +1 @@
+__version__ = '0.0.1'
diff --git a/gerbonara/cli.py b/gerbonara/cli.py
new file mode 100644
index 0000000..5d7ef65
--- /dev/null
+++ b/gerbonara/cli.py
@@ -0,0 +1,39 @@
+from os import path, listdir
+from glob import glob
+
+from . import __version__
+
+import click
+
+
+@click.group()
+@click.version_option(__version__)
+def cli():
+ pass
+
+
+@click.command()
+@click.option('-o', '--outfile', type=click.File(mode='wb'), help='Output Filename (extension will be added automatically)')
+@click.option('-t', '--theme', default='default', type=click.Choice(['default', 'OSH Park', 'Blue', 'Transparent Copper', 'Transparent Multilayer'], case_sensitive=False), help='Select render theme')
+@click.option('-w', '--width', type=click.INT, help='Maximum width')
+@click.option('-h', '--height', type=click.INT, help='Maximum height')
+@click.option('-v', '--verbose', is_flag=True, help='Increase verbosity of the output')
+@click.argument('filenames', nargs=-1, type=click.Path(exists=True))
+def render(outfile, theme, width, height, verbose, filenames):
+ """Render gerber files to image. If a directory is provided, it should be provided alone and should contain the gerber files for a single PCB."""
+ if len(filenames) == 0:
+ raise click.UsageError(message='No files or folders provided')
+ if len(filenames) > 1:
+ for f in filenames:
+ if path.isdir(f):
+ raise click.UsageError(message='If a directory is provided, it should be provided alone and should contain the gerber files for a single PCB')
+
+ # list files if folder id given
+ if len(filenames) == 1 and path.isdir(filenames[0]):
+ filenames = listdir(filenames[0])
+ #filenames = [f for f in glob(f'{filenames[0]}/*.txt')]
+
+ click.echo(f'render {filenames} with theme {theme}')
+
+
+cli.add_command(render)
diff --git a/setup.py b/setup.py
index ce3797b..f26885a 100644
--- a/setup.py
+++ b/setup.py
@@ -13,7 +13,7 @@ def long_description():
def version():
- with open(join(abspath(dirname(__file__)), 'gerber/__init__.py')) as fh:
+ with open(join(abspath(dirname(__file__)), 'gerbonara/__init__.py')) as fh:
for line in fh:
if line.startswith('__version__'):
ver = line.split("'")[1]
@@ -43,7 +43,12 @@ setup(
'Tracker': 'https://gitlab.com/gerbonara/gerbonara/issues',
},
packages=find_packages(exclude=['tests']),
- install_requires=[],
+ install_requires=['click'],
+ entry_points={
+ 'console_scripts': [
+ 'gerbonara = gerbonara.cli:cli',
+ ],
+ },
classifiers=[
'Development Status :: 1 - Planning',
#'Development Status :: 3 - Alpha',