]> git.ipfire.org Git - dbl.git/commitdiff
dnsbl: Add a command to show information about a list
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Dec 2025 16:31:58 +0000 (16:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 5 Dec 2025 16:31:58 +0000 (16:31 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
configure.ac
src/scripts/dnsbl.in

index faaaf23290963ec5caceb6d5b4aa0b309ade1891..5f232b15e9e10005a318df30f6b8ae11fdf10ea0 100644 (file)
@@ -52,6 +52,7 @@ AC_PROG_MKDIR_P
 # Python
 AM_PATH_PYTHON([3.13])
 
+AX_PYTHON_MODULE([rich], [fatal])
 AX_PYTHON_MODULE([sqlmodel], [fatal])
 
 # ------------------------------------------------------------------------------
index a771ba76237e816761ccb23d97195bae99e7b994..04eaf94b372dd055dfc5d9bcb41287284cd5c131 100644 (file)
@@ -23,12 +23,18 @@ import argparse
 import dnsbl
 import logging
 import os
+import rich.console
+import rich.table
 import sys
 
 # i18n
 from dnsbl.i18n import _
 
 class CLI(object):
+       def __init__(self):
+               # Initialize the console
+               self.console = rich.console.Console()
+
        def parse_cli(self):
                """
                        Main Function.
@@ -56,6 +62,11 @@ class CLI(object):
                                help=_("The license of the list"))
                list_create.set_defaults(func=self.__list_create)
 
+               # list-show
+               list_show = subparsers.add_parser("list-show", help=_("Shows details about a list"))
+               list_show.add_argument("list", help=_("The name of the list"))
+               list_show.set_defaults(func=self.__list_show)
+
                # list-add-source
                list_add_source = subparsers.add_parser("list-add-source",
                                help=_("Creates a new source to a list"))
@@ -120,6 +131,44 @@ class CLI(object):
                        license    = args.license,
                )
 
+       def __list_show(self, backend, args):
+               """
+                       Shows information about a list
+               """
+               list = backend.lists.get_by_slug(args.list)
+
+               table = rich.table.Table(title=list.name)
+               table.add_column(_("Property"))
+               table.add_column(_("Value"))
+
+               table.add_row(_("Name"), list.name)
+               table.add_row(_("License"), list.license)
+               table.add_row(_("Created At"), list.created_at.isoformat())
+               table.add_row(_("Created By"), list.created_by)
+
+               # Print list properties
+               self.console.print(table)
+
+               # Show all sources
+               table = rich.table.Table(title=_("Sources"))
+               table.add_column(_("Name"))
+               table.add_column(_("License"))
+               table.add_column(_("URL"))
+               table.add_column(_("Created At"))
+               table.add_column(_("Created_By"))
+
+               for source in list.sources:
+                       table.add_row(
+                               source.name,
+                               source.license,
+                               source.url,
+                               source.created_at.isoformat(),
+                               source.created_by,
+                       )
+
+               # Print the sources
+               self.console.print(table)
+
        def __list_add_source(self, backend, args):
                """
                        Adds a new source to a list