Skip to content

Commit 470615d

Browse files
make boolean options show up properly in usage page
1 parent 28ed3f4 commit 470615d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

release.py

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import re
55
import sys
66

7+
# pylint: disable=unspecified-encoding,missing-function-docstring
8+
79

810
def cmd(sh_line):
911
print(sh_line)

schemascii/configs.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ConfigConfig:
1818
"Scale at which to enlarge the entire diagram by."),
1919
ConfigConfig("stroke_width", float, 2, "Width of the lines"),
2020
ConfigConfig("stroke", str, "black", "Color of the lines."),
21-
ConfigConfig("label", ["", "VL", "L", "V"], "VL",
21+
ConfigConfig("label", ["L", "V", "VL"], "VL",
2222
"Component label style (L=include label, V=include value, VL=both)"),
2323
ConfigConfig("nolabels", bool, False,
2424
"Turns off labels on all components, except for part numbers on ICs."),
@@ -34,6 +34,11 @@ def add_config_arguments(a: argparse.ArgumentParser):
3434
help=opt.description,
3535
choices=opt.clazz,
3636
default=opt.default)
37+
elif opt.clazz is bool:
38+
a.add_argument(
39+
"--" + opt.name,
40+
help=opt.description,
41+
action="store_false" if opt.default else "store_true")
3742
else:
3843
a.add_argument(
3944
"--" + opt.name,
@@ -51,7 +56,8 @@ def apply_config_defaults(options: dict) -> dict:
5156
if isinstance(opt.clazz, list):
5257
if options[opt.name] not in opt.clazz:
5358
raise ArgumentError(
54-
f"config option {opt.name}: invalid choice: {options[opt.name]} "
59+
f"config option {opt.name}: "
60+
f"invalid choice: {options[opt.name]} "
5561
f"(valid options are {', '.join(map(repr, opt.clazz))})")
5662
continue
5763
try:

0 commit comments

Comments
 (0)