@synthart/synthlite
Version:
A fast, lightweight Gen AI powered synthetic data generator written in TypeScript. 🌞
71 lines (70 loc) • 3.21 kB
JavaScript
;
/**
*
* @file cli.ts
* @author Aditya Patange (AdiPat) <contact.adityapatange@gmail.com>
* @description 🚀 CLI is a class that handles command-line interface operations.
* @date January 2024
* @version 1.0.0
* @license Affero General Public License v3.0
* ✨ "Wise speaks, symbols breathe." — IA
*
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLI = void 0;
const commander_1 = require("commander");
const common_1 = require("../common");
const package_json_1 = __importDefault(require("../../package.json"));
/**
* CLI: Handles command-line interface operations.
* @class CLI
*/
class CLI {
/**
* Retrieves and validates command-line options.
* @returns {Promise<CLIOptions>} - A promise that resolves to the CLI options.
*/
static getOptions() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
const program = new commander_1.Command();
program
.name("synthlite")
.description("SynthLite: A fast, lightweight and flexible synthetic data generation tool.")
.version(package_json_1.default.version)
.option("-v, --verbose", "Enable verbose mode")
.option("-sc, --schema <schema>", "Path to the schema file")
.option("-o, --output <output>", "Path to the output file")
.option("-r, --rows <rows>", "Number of rows to generate")
.option("-f, --format <format>", "Output format (json/csv)")
.option("-env, --env <env>", "Path to the environment file");
program.parse(process.argv);
const options = program.opts();
const envPath = yield common_1.Validator.validateEnvPath(options.env);
yield common_1.Validator.validateCLIOptions(options);
common_1.Config.loadEnv(envPath);
const verbose = options.verbose == undefined ? false : options.verbose;
return {
verbose,
schema: options.schema,
output: options.output,
rows: (_a = options.rows) !== null && _a !== void 0 ? _a : common_1.Constants.DEFAULT_ROWS,
format: options.format || "json",
envPath: options.env || ".env",
};
});
}
}
exports.CLI = CLI;