forked from jeroen94704/klepcbgen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathklepcbgen.py
40 lines (36 loc) · 1.26 KB
/
klepcbgen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
from klepcbgenmod import *
import argparse
def parse_command_line_arguments():
""" Parse the command line and check that the correct number of arguments is given """
parser = argparse.ArgumentParser(
prog="klepcbgen",
description="Utility to generate a KiCad schematic and layout of the switch matrix of \
a keyboard designed using the Keyboard Layout Editor \
(http://www.keyboard-layout-editor.com/)",
)
parser.add_argument(
"-v", "--version", action="version", version="%(prog)s " + PROGRAM_VERSION
)
parser.add_argument(
"infile",
help="A JSON file containing a keyboard layout in the KLE JSON format",
)
parser.add_argument(
"outname",
help='The base name of the output files (e.g. "id80" will result in "id80.sch" and \
"id80.pcb"',
)
args = parser.parse_args()
if not args.infile:
print("")
parser.error(
"Not all required arguments are present. Use the options '-h' for more information"
)
return args
# Program entry
if __name__ == "__main__":
arguments = parse_command_line_arguments()
kbpcbgen = KLEPCBGenerator()
kbpcbgen.generate_kicadproject(arguments)
kbpcbgen.keyboard.print_key_info()