Order output of CLI list commands
This commit is contained in:
@@ -18,7 +18,7 @@ from .models import (
|
|||||||
|
|
||||||
def cmd_user_list(args, app):
|
def cmd_user_list(args, app):
|
||||||
"""List all users."""
|
"""List all users."""
|
||||||
users = User.select()
|
users = User.select().order_by(User.username)
|
||||||
if not users:
|
if not users:
|
||||||
print("No users found.")
|
print("No users found.")
|
||||||
return 0
|
return 0
|
||||||
@@ -144,13 +144,15 @@ def cmd_hostname_list(args, app):
|
|||||||
print(f"Error: User '{args.user}' not found.")
|
print(f"Error: User '{args.user}' not found.")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
query = query.order_by(User.username, Hostname.hostname, Hostname.zone)
|
||||||
|
|
||||||
hostnames = list(query)
|
hostnames = list(query)
|
||||||
if not hostnames:
|
if not hostnames:
|
||||||
print("No hostnames found.")
|
print("No hostnames found.")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
print(
|
print(
|
||||||
f"\n{'Hostname':<35} {'User':<15} {'Zone':<20} "
|
f"\n{'Hostname':<35} {'Zone':<20} {'User':<15} "
|
||||||
f"{'DNS-TTL':<8} {'Exp-TTL':<8} {'Last-Update IPv4':<25} {'Last-Update IPv6'}"
|
f"{'DNS-TTL':<8} {'Exp-TTL':<8} {'Last-Update IPv4':<25} {'Last-Update IPv6'}"
|
||||||
)
|
)
|
||||||
print("-" * 140)
|
print("-" * 140)
|
||||||
@@ -158,7 +160,7 @@ def cmd_hostname_list(args, app):
|
|||||||
last_ipv4_update = datetime_str(h.last_ipv4_update)
|
last_ipv4_update = datetime_str(h.last_ipv4_update)
|
||||||
last_ipv6_update = datetime_str(h.last_ipv6_update)
|
last_ipv6_update = datetime_str(h.last_ipv6_update)
|
||||||
print(
|
print(
|
||||||
f"{h.hostname:<35} {h.user.username:<15} {h.zone:<20} "
|
f"{h.hostname:<35} {h.zone:<20} {h.user.username:<15} "
|
||||||
f"{h.dns_ttl:<8} {h.expiry_ttl:<8} {last_ipv4_update:<25} {last_ipv6_update}"
|
f"{h.dns_ttl:<8} {h.expiry_ttl:<8} {last_ipv4_update:<25} {last_ipv6_update}"
|
||||||
)
|
)
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user