2021-07-14 10:06:58 +02:00
|
|
|
import json
|
|
|
|
import sys
|
2021-10-14 09:06:14 +02:00
|
|
|
import re
|
2021-07-14 10:06:58 +02:00
|
|
|
|
|
|
|
header = """
|
|
|
|
Mailserver Options
|
|
|
|
==================
|
|
|
|
|
|
|
|
mailserver
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
template = """
|
|
|
|
{key}
|
|
|
|
{line}
|
|
|
|
|
|
|
|
{description}
|
|
|
|
|
|
|
|
{type}
|
|
|
|
{default}
|
|
|
|
"""
|
|
|
|
|
|
|
|
f = open(sys.argv[1])
|
|
|
|
options = json.load(f)
|
|
|
|
|
2021-10-14 09:06:14 +02:00
|
|
|
options = {k: v for k, v in options.items()
|
|
|
|
if k.startswith("mailserver.")}
|
|
|
|
|
|
|
|
groups = ["mailserver.loginAccount",
|
|
|
|
"mailserver.certificate",
|
|
|
|
"mailserver.dkim",
|
|
|
|
"mailserver.fullTextSearch",
|
|
|
|
"mailserver.redis",
|
|
|
|
"mailserver.monitoring",
|
|
|
|
"mailserver.backup",
|
|
|
|
"mailserver.borg"]
|
2021-07-14 10:06:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
def print_option(name, value):
|
2021-10-14 09:06:14 +02:00
|
|
|
if 'default' in value:
|
|
|
|
if value['default'] == "":
|
2021-07-14 10:06:58 +02:00
|
|
|
default = '- Default: ``""``'
|
|
|
|
else:
|
|
|
|
default = '- Default: ``{}``'.format(v['default'])
|
2021-10-14 09:06:14 +02:00
|
|
|
# Some default values contains OUTPUTPATHS which make the
|
|
|
|
# output not stable across nixpkgs updates.
|
|
|
|
default = re.sub('/nix/store/[\w.-]*/', '<OUTPUT-PATH>/', default) # noqa
|
2021-07-14 10:06:58 +02:00
|
|
|
else:
|
|
|
|
default = ""
|
|
|
|
print(template.format(
|
2021-10-14 09:06:14 +02:00
|
|
|
key=name,
|
|
|
|
line="-"*len(name),
|
|
|
|
description=value['description'],
|
|
|
|
type="- Type: ``{}``".format(value['type']),
|
2021-07-14 10:06:58 +02:00
|
|
|
default=default))
|
|
|
|
|
2021-10-14 09:06:14 +02:00
|
|
|
|
2021-07-14 10:06:58 +02:00
|
|
|
print(header)
|
|
|
|
for k, v in options.items():
|
|
|
|
if any([k.startswith(c) for c in groups]):
|
|
|
|
continue
|
|
|
|
print_option(k, v)
|
|
|
|
|
|
|
|
for c in groups:
|
|
|
|
print(c)
|
|
|
|
print("~"*len(c))
|
|
|
|
print()
|
|
|
|
for k, v in options.items():
|
|
|
|
if k.startswith(c):
|
|
|
|
print_option(k, v)
|