defmodule Mix.Tasks.SoftPos.List.Clients do @moduledoc """ Lists all OAuth2.0 clients for SoftPOS API. ## Usage mix soft_pos.list.clients This will display all registered OAuth clients with their details (excluding client secrets for security). """ use Mix.Task alias DaProductApp.SoftPos.OauthApplications @shortdoc "List all OAuth clients for SoftPOS API" @impl Mix.Task def run(_args) do Mix.Task.run("app.start") clients = OauthApplications.list_applications() if Enum.empty?(clients) do Mix.shell().info("No OAuth clients found.") else Mix.shell().info("\nOAuth Clients for SoftPOS API:") Mix.shell().info("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n") Enum.each(clients, fn client -> Mix.shell().info(""" Name: #{client.name} Client ID: #{client.uid} Scopes: #{client.scopes} Created: #{Calendar.strftime(client.inserted_at, "%Y-%m-%d %H:%M:%S UTC")} ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ """) end) Mix.shell().info("Total clients: #{length(clients)}\n") end end end