UNPKG

@sap/cli-core

Version:

Command-Line Interface (CLI) Core Module

29 lines (28 loc) 1.02 kB
import { getMetadata } from "../../../discovery/index.js"; import { get as getLogger } from "../../../logger/index.js"; import { createNextHandler, createParseArgumentsHandler, } from "../../handler/index.js"; const show = async () => async () => { const { output } = getLogger("commands.show"); const metadata = await getMetadata(); if (metadata.length === 0) { output("Local CLI cache is empty"); throw new Error("local CLI cache is empty"); } else { output(JSON.stringify(metadata.map((m) => { const addedAt = new Date(); addedAt.setTime(m.addedAt); return { tenant: m.tenant, addedAt: addedAt.toLocaleString(), }; }), null, 2)); } }; const showCommand = { type: "command", command: "show", description: "display local CLI cache entries", handler: createNextHandler("command.config.cache.show", createParseArgumentsHandler(), show), }; export default showCommand;