import { parseArgs } from "@std/cli/parse-args"; import { ConfigManager } from "../auth/config.ts"; function showStatusHelp() { console.log(` slices status - Show authentication and configuration status USAGE: slices status [OPTIONS] OPTIONS: -h, --help Show this help message EXAMPLES: slices status `); } export async function statusCommand(commandArgs: unknown[], _globalArgs: Record): Promise { const args = parseArgs(commandArgs as string[], { boolean: ["help"], alias: { h: "help", }, }); if (args.help) { showStatusHelp(); return; } const config = new ConfigManager(); await config.load(); if (config.isAuthenticated()) { const authConfig = config.get().auth!; console.log(`Authenticated as ${authConfig.did}`); console.log(`API: ${config.get().apiBaseUrl}`); if (authConfig.expiresAt) { const expiresIn = Math.round((authConfig.expiresAt - Date.now()) / 1000); if (expiresIn > 0) { const hours = Math.floor(expiresIn / 3600); const minutes = Math.floor((expiresIn % 3600) / 60); if (hours > 0) { console.log(`Token expires in ${hours}h ${minutes}m`); } else if (minutes > 0) { console.log(`Token expires in ${minutes}m`); } else { console.log(`Token expires in ${expiresIn}s`); } } else { console.log("Token has expired - run 'slices login' to re-authenticate"); } } } else { console.log("Not authenticated - run 'slices login' to authenticate"); } }