Export a (working!) default config file
This commit is contained in:
parent
f5e8ff6b5d
commit
9c6b8971b6
2 changed files with 15 additions and 4 deletions
|
|
@ -85,13 +85,20 @@ def run(args: Any) -> None:
|
|||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-c", "--config-file")
|
||||
parser.add_argument("-c", "--config-file", type=Path)
|
||||
parser.add_argument("-v", "--verbose", action="store_true")
|
||||
parser.add_argument("--export-default-config", type=Path)
|
||||
args = parser.parse_args()
|
||||
|
||||
level = logging.DEBUG if args.verbose else logging.INFO
|
||||
logging.basicConfig(level=level, style=LOG_STYLE, format=LOG_FORMAT)
|
||||
|
||||
if args.export_default_config is not None:
|
||||
logger.info(f"Exporting default config to {style_path(args.export_default_config)}")
|
||||
with open(args.export_default_config, "w") as f:
|
||||
f.write(DEFAULT_CONFIG.to_config_file())
|
||||
return
|
||||
|
||||
try:
|
||||
run(args)
|
||||
except CatastrophicError as e:
|
||||
|
|
|
|||
|
|
@ -81,12 +81,16 @@ class DefaultConfig:
|
|||
for name in sorted(self._values):
|
||||
value = self._values[name]
|
||||
|
||||
line: str
|
||||
if value.has_constant_value:
|
||||
lines.append(f"{name} = {value.value!r} # {value.description}\n")
|
||||
line = f"{name} = {value.value!r}"
|
||||
else:
|
||||
lines.append(f"# {name} : {value.description}\n")
|
||||
line = f"# {name}"
|
||||
|
||||
return "".join(lines)
|
||||
line = f"{line:<32} # {value.description}"
|
||||
lines.append(line)
|
||||
|
||||
return "\n".join(lines) + "\n"
|
||||
|
||||
DEFAULT_CONFIG = DefaultConfig()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue