"use strict"; import path from 'path'; import CliParser from 'applause-cli'; import train from './subcommands/train/train.mjs'; import predict from './subcommands/predict/predict.mjs'; const __dirname = import.meta.url.slice(7, import.meta.url.lastIndexOf("/")); export default async function () { let cli = new CliParser(path.resolve(__dirname, "../package.json")); cli.subcommand("train", "Trains a new AI") .argument("input", "The input directory containing the training data", null, "string") .argument("output", "Path to the output directory to save the trained AI to"); cli.subcommand("predict", "Predicts the genres of the specified image") .argument("input", "Path to the input image") .argument("ai-model", "Path to the saved AI model to load"); let settings = cli.parse(process.argv.slice(2)); if(cli.current_subcommand == null) { cli.write_help_exit(); return; } switch(cli.current_subcommand) { case "train": await train(settings); break; case "predict": await predict(settings); break; default: console.error(`Error: Unknown subcommand '${cli.current_subcommand}' (try --help for usage information)`); process.exit(1); break; } }