import { getArg } from './lib/args.js';
import { createDb } from './lib/schema.js';
import { error } from './lib/log.js';

const ctx = 'initDb.js';

/**
 * Initializes a user db from a list of existing directories
 * at the specified `--path` parameter when executing the command.
 * Useful when there is already a collection of folders.
 */
export const initDb = async () => {
  let directory = '';
  try {
    directory = getArg('path');
  } catch (err) {
    error(ctx, err);
    return;
  }
  createDb();
};

initDb();