UNPKG

askexperts

Version:

AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol

45 lines 1.66 kB
import { getDocstore, createDocstoreClient } from "./index.js"; import { debugError, enableAllDebug } from "../../../common/debug.js"; /** * Delete a document from a docstore * @param id Document ID * @param options Command options */ export async function deleteDoc(id, options) { try { // Enable debug output if debug flag is set if (options.debug) { enableAllDebug(); } const docstoreClient = await createDocstoreClient(options); const docstore = await getDocstore(docstoreClient, options.docstore); const result = await docstoreClient.delete(docstore.id, id); if (result) { console.log(`Document with ID '${id}' deleted successfully`); } else { debugError(`Document with ID '${id}' not found in docstore '${docstore.id}'`); process.exit(1); } docstoreClient[Symbol.dispose](); } catch (error) { debugError(`Error deleting document: ${error}`); process.exit(1); } } /** * Register the delete command * @param docstoreCommand The parent docstore command * @param addPathOption Function to add path option to command */ export function registerDeleteCommand(docstoreCommand, addCommonOptions) { const deleteCommand = docstoreCommand .command("delete") .description("Delete a document from a docstore") .argument("<id>", "ID of the document to delete") .option("-s, --docstore <id>", "ID of the docstore (required if more than one docstore exists)") .action(deleteDoc); addCommonOptions(deleteCommand); } //# sourceMappingURL=delete.js.map