+# PyNSC: Command-line interface
+# (c) 2024 Martin Mareš <mj@ucw.cz>
+
import argparse
from argparse import Namespace
from pathlib import Path
from nsconfig.core import Nsc, NscZonePrimary, NscZoneSecondary, NscZoneAlias
-def do_test(nsc: Nsc) -> None:
- test_dir = Path('test')
+def do_test(nsc: Nsc, args: Namespace) -> None:
+ test_dir = Path(args.output)
test_dir.mkdir(exist_ok=True)
for z in nsc.get_zones():
print(f'Zone: {z.name}')
subparsers = parser.add_subparsers(help='action to perform', dest='action', required=True, metavar='ACTION')
test_parser = subparsers.add_parser('test', help='test new configuration', description='Test new configuration')
+ test_parser.add_argument('-o', '--output', metavar='DIR', default='test', help='directory to dump configuration to (default: "test")')
status_parser = subparsers.add_parser('status', help='list status of zones', description='List status of zones')
status_parser.add_argument('-a', '--all', default=False, action='store_true', help='show non-primary zones')
nsc.process()
if args.action == 'test':
- do_test(nsc)
+ do_test(nsc, args)
elif args.action == 'status':
do_status(nsc, args)
elif args.action == 'update':