forked from HashLips/hashlips_art_engine
-
Notifications
You must be signed in to change notification settings - Fork 207
Open
Description
Proposed index.js
"use strict";
const path = require("path");
const isLocal = typeof process.pkg === "undefined";
const basePath = isLocal ? process.cwd() : path.dirname(process.execPath);
const fs = require("fs");
const { Command } = require("commander");
const program = new Command();
const chalk = require("chalk");
const { startCreating, buildSetup } = require(path.join(
basePath,
"/src/main.js"
));
program
.name("generate")
.argument("[dna-file]", "DNA file to continue generation from")
.option("-c, --continue", "Continue generation mode")
.action((dnaFile, options) => {
console.log(chalk.green("generator started"));
if (dnaFile || options.continue) {
console.log(
chalk.bgCyanBright("\n continuing generation using _dna.json file \n")
);
}
buildSetup();
let dna = null;
if (dnaFile) {
try {
const dnaFilePath = path.resolve(dnaFile);
if (!fs.existsSync(dnaFilePath)) {
console.error(chalk.red(`Error: DNA file not found at: ${dnaFilePath}`));
process.exit(1);
}
const storedGenomes = JSON.parse(fs.readFileSync(dnaFilePath, 'utf8'));
dna = new Set(storedGenomes);
console.log(chalk.green(`Loaded ${storedGenomes.length} DNA entries`));
} catch (error) {
console.error(chalk.red(`Error reading DNA file: ${error.message}`));
process.exit(1);
}
}
startCreating(dna);
});
program.parse();Usage
# Continue generation with DNA file
node generate.js build/_dna.json
# Continue generation with flag (if no file specified)
node generate.js -c
# Both can be used together
node generate.js build/_dna.json -cReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels