import { pushCommand } from "./lexicon/push.ts"; import { pullCommand } from "./lexicon/pull.ts"; import { listCommand } from "./lexicon/list.ts"; function showLexiconHelp() { console.log(` slices lexicon - Manage lexicons USAGE: slices lexicon [OPTIONS] SUBCOMMANDS: push Push lexicon files to your slice pull Pull lexicon files from your slice list List lexicons in your slice help Show this help message OPTIONS: -h, --help Show help information EXAMPLES: slices lexicon push --slice at://did:plc:example/slice slices lexicon pull --slice at://did:plc:example/slice slices lexicon list --slice at://did:plc:example/slice slices lexicon help `); } export async function lexiconCommand( commandArgs: unknown[], globalArgs: Record ): Promise { // Use the same pattern as main CLI - find subcommand in raw args const rawArgs = commandArgs as string[]; if (rawArgs.length === 0) { showLexiconHelp(); return; } // If the first arg is help or --help, show lexicon help if ( rawArgs[0] === "help" || (rawArgs.length === 1 && (rawArgs[0] === "--help" || rawArgs[0] === "-h")) ) { showLexiconHelp(); return; } const subcommand = rawArgs[0]; // Find the subcommand index and pass everything after it const subcommandIndex = rawArgs.findIndex((arg) => arg === subcommand); const subcommandArgs = subcommandIndex >= 0 ? rawArgs.slice(subcommandIndex + 1) : []; try { switch (subcommand) { case "push": await pushCommand(subcommandArgs, globalArgs); break; case "pull": await pullCommand(subcommandArgs, globalArgs); break; case "list": await listCommand(subcommandArgs, globalArgs); break; case "help": showLexiconHelp(); break; default: console.error(`Unknown lexicon subcommand: ${subcommand}`); console.error("Run 'slices lexicon help' for usage information."); Deno.exit(1); } } catch (error) { const err = error as Error; console.error(`Lexicon command failed: ${err.message}`); Deno.exit(1); } }