diff --git a/src/collections.ts b/src/collections.ts index 6cce4ef..f13ba70 100644 --- a/src/collections.ts +++ b/src/collections.ts @@ -50,6 +50,17 @@ export interface NamedCollection extends Collection { // Configuration paths // ============================================================================ +// Current index name (default: "index") +let currentIndexName: string = "index"; + +/** + * Set the current index name for config file lookup + * Config file will be ~/.config/qmd/{indexName}.yml + */ +export function setConfigIndexName(name: string): void { + currentIndexName = name; +} + function getConfigDir(): string { // Allow override via QMD_CONFIG_DIR for testing if (process.env.QMD_CONFIG_DIR) { @@ -59,7 +70,7 @@ function getConfigDir(): string { } function getConfigFilePath(): string { - return join(getConfigDir(), "index.yml"); + return join(getConfigDir(), `${currentIndexName}.yml`); } /** diff --git a/src/qmd.ts b/src/qmd.ts index 29fd2d1..97d1953 100755 --- a/src/qmd.ts +++ b/src/qmd.ts @@ -81,6 +81,7 @@ import { removeContext as yamlRemoveContext, setGlobalContext, listAllContexts, + setConfigIndexName, } from "./collections.js"; // Enable production mode - allows using default database path @@ -2291,6 +2292,9 @@ function parseCLI() { args: Bun.argv.slice(2), // Skip bun and script path options: { // Global options + index: { + type: "string", + }, context: { type: "string", }, @@ -2331,6 +2335,7 @@ function parseCLI() { const indexName = values.index as string | undefined; if (indexName) { setIndexName(indexName); + setConfigIndexName(indexName); } // Determine output format