]> mj.ucw.cz Git - pynsc.git/commitdiff
Let "status" command shorten long zone names
authorMartin Mares <mj@ucw.cz>
Mon, 22 Apr 2024 13:29:57 +0000 (15:29 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 22 Apr 2024 13:29:57 +0000 (15:29 +0200)
nsconfig/cli.py

index 8367aa211a78226c001b91ac793564d7d6974d32..46f04fdacff66b77508bc71297f3a047b08f62e0 100644 (file)
@@ -56,11 +56,14 @@ def do_status(nsc: Nsc, args: Namespace) -> None:
         elif isinstance(z, NscZoneSecondary):
             status = f'from {z.primary_server}'
         elif isinstance(z, NscZoneAlias):
-            status = f'to {z.alias_for.name}'
+            status = f'for "{z.alias_for.name}"'
         else:
             raise NotImplementedError()
+        name = z.name
+        if len(name) > 30 and not args.long:
+            name = name[:16] + '[...]' + name[-16:]
         if do_show:
-            table.add_row([action, z.name, z.zone_type.name, status])
+            table.add_row([action, name, z.zone_type.name, status])
 
     print(table.draw())
 
@@ -88,6 +91,7 @@ def main(nsc: Nsc) -> None:
 
     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')
+    status_parser.add_argument('-l', '--long', default=False, action='store_true', help='do not abbreviate zone names')
 
     update_parser = subparsers.add_parser('update', help='update configuration', description='Update zone files and daemon configuration as needed')