systemquery/src/subcommands/agent/agent.mjs
Starbeamrainbowlabs 135b2e8d1b
Write a bunch more glue code
....but it's all still untested. I'm getting kinda nervous here
2022-01-08 16:59:08 +00:00

26 lines
815 B
JavaScript

"use strict";
import fs from 'fs';
import path from 'path';
import settings from '../../settings.mjs';
import toml_settings_read from '../../lib/io/TomlSettings.mjs';
import Agent from '../../lib/agent/Agent.mjs';
// HACK: Make sure __dirname is defined when using es6 modules. I forget where I found this - a PR with a source URL would be great :D
const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/"));
export default async function () {
if(!fs.existsSync(settings.cli.config))
throw new Error(`Error: The config file at '${settings.cli.config}' doesn't appear to exist, or we don't have permission to access it.`);
let config = toml_settings_read(
path.join(__dirname, "config.default.toml"),
settings.cli.config
);
let agent = new Agent(config);
await agent.init();
}