XD-DENG commented on a change in pull request #12704:
URL: https://github.com/apache/airflow/pull/12704#discussion_r532877922



##########
File path: airflow/cli/commands/pool_command.py
##########
@@ -21,61 +21,74 @@
 import sys
 from json import JSONDecodeError
 
-from tabulate import tabulate
-
 from airflow.api.client import get_current_api_client
+from airflow.cli.simple_table import AirflowConsole
 from airflow.utils import cli as cli_utils
+from airflow.utils.cli import suppress_logs_and_warning
 
 
-def _tabulate_pools(pools, tablefmt="fancy_grid"):
-    return "\n%s" % tabulate(pools, ['Pool', 'Slots', 'Description'], 
tablefmt=tablefmt)
+def _show_pools(pools, output):
+    AirflowConsole().print_as(
+        data=pools,
+        output=output,
+        mapper=lambda x: {
+            "pool": x[0],
+            "slots": x[1],
+            "description": x[2],
+        },
+    )
 
 
+@suppress_logs_and_warning()
 def pool_list(args):
     """Displays info of all the pools"""
     api_client = get_current_api_client()
     pools = api_client.get_pools()
-    print(_tabulate_pools(pools=pools, tablefmt=args.output))
+    _show_pools(pools=pools, output=args.output)
 
 
+@suppress_logs_and_warning()
 def pool_get(args):
     """Displays pool info by a given name"""
     api_client = get_current_api_client()
     pools = [api_client.get_pool(name=args.pool)]
-    print(_tabulate_pools(pools=pools, tablefmt=args.output))
+    _show_pools(pools=pools, output=args.output)
 
 
 @cli_utils.action_logging
+@suppress_logs_and_warning()
 def pool_set(args):
     """Creates new pool with a given name and slots"""
     api_client = get_current_api_client()
     pools = [api_client.create_pool(name=args.pool, slots=args.slots, 
description=args.description)]
-    print(_tabulate_pools(pools=pools, tablefmt=args.output))
+    _show_pools(pools=pools, output=args.output)
 
 
 @cli_utils.action_logging
+@suppress_logs_and_warning()
 def pool_delete(args):
     """Deletes pool by a given name"""
     api_client = get_current_api_client()
     pools = [api_client.delete_pool(name=args.pool)]
-    print(_tabulate_pools(pools=pools, tablefmt=args.output))
+    _show_pools(pools=pools, output=args.output)
 
 
 @cli_utils.action_logging
+@suppress_logs_and_warning()
 def pool_import(args):
     """Imports pools from the file"""
     if not os.path.exists(args.file):
         sys.exit("Missing pools file.")
     pools, failed = pool_import_helper(args.file)
-    print(_tabulate_pools(pools=pools, tablefmt=args.output))
+    _show_pools(pools=pools, output=args.output)
     if len(failed) > 0:
         sys.exit("Failed to update pool(s): {}".format(", ".join(failed)))
 
 
 def pool_export(args):
     """Exports all of the pools to the file"""
     pools = pool_export_helper(args.file)
-    print(_tabulate_pools(pools=pools, tablefmt=args.output))
+    _show_pools(pools=pools, output=args.output)

Review comment:
       Personally I agree with the three points you raised (including this one).




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to