askexperts
Version:
AskExperts SDK: build and use AI experts - ask them questions and pay with bitcoin on an open protocol
45 lines • 1.5 kB
JavaScript
import { createDocstoreClient } from "./index.js";
import { debugError, enableAllDebug } from "../../../common/debug.js";
/**
* List all docstores
* @param options Command options
*/
export async function listDocstores(options) {
try {
// Enable debug output if debug flag is set
if (options.debug) {
enableAllDebug();
}
// Create docstore client based on options
const docstoreClient = await createDocstoreClient(options);
// List docstores
const docstores = await docstoreClient.listDocstores();
if (docstores.length === 0) {
console.log("No docstores found");
}
else {
console.log("Docstores:");
docstores.forEach((ds) => {
console.log(` ID: ${ds.id}, Name: ${ds.name}, Created: ${new Date(ds.timestamp * 1000).toISOString()}`);
});
}
docstoreClient[Symbol.dispose]();
}
catch (error) {
debugError(`Error listing docstores: ${error}`);
process.exit(1);
}
}
/**
* Register the list command
* @param docstoreCommand The parent docstore command
* @param addPathOption Function to add path option to command
*/
export function registerListCommand(docstoreCommand, addCommonOptions) {
const lsCommand = docstoreCommand
.command("ls")
.description("List all docstores")
.action(listDocstores);
addCommonOptions(lsCommand);
}
//# sourceMappingURL=ls.js.map