code: def _list_app_commands(echo: bool = True) -> List[str]:
      metadata = _get_commands_metadata()
      metadata = {
          key.replace("_", " "): value
          for key, value in metadata.items()
      }
  
      command_names = sorted(metadata.keys())
      if not command_names:
          click.echo("The current Lightning App doesn't have commands.")
          return []
  
      app_info = metadata[command_names[0]].get("app_info", None)
  
      title, description, on_connect_end = "Lightning", None, None
      if app_info:
          title = app_info.get("title")
          description = app_info.get("description")
          on_connect_end = app_info.get("on_connect_end")
  
      if echo:
          click.echo(f"{title} App")
          if description:
              click.echo("")
              click.echo("Description:")
              if description.endswith("\n"):
                  description = description[:-2]
              click.echo(f"  {description}")
          click.echo("")
          click.echo("Commands:")
          max_length = max(len(n) for n in command_names)
          for command_name in command_names:
              padding = (max_length + 1 - len(command_name)) * " "
              click.echo(
                  f"  {command_name}{padding}{metadata[command_name].get('description', '')}"
              )
          if "LIGHTNING_CONNECT_PPID" in os.environ and on_connect_end:
              if on_connect_end.endswith("\n"):
                  on_connect_end = on_connect_end[:-2]
              click.echo(on_connect_end)
      return command_names
  
imports: import json
  import os
  import shutil
  import sys
  from subprocess import Popen
  from typing import List, Optional, Tuple
  import click
  import psutil
  from lightning_utilities.core.imports import package_available
  from rich.progress import Progress
  from lightning.app.utilities.cli_helpers import _get_app_display_name, _LightningAppOpenAPIRetriever
  from lightning.app.utilities.cloud import _get_project
  from lightning.app.utilities.enum import OpenAPITags
  from lightning.app.utilities.log import get_logfile
  from lightning.app.utilities.network import LightningClient
label_desc: Use image node_id 9 for calling a global function with example usage: _list_app_commands(echo) and returns: command_names, list