UNPKG

@vscubing/cubing

Version:

A collection of JavaScript cubing libraries.

56 lines (54 loc) 1.55 kB
#!/usr/bin/env -S node -- import { packageVersion } from "./chunks/chunk-BSOKOGXQ.js"; // src/bin/order.ts import { basename } from "node:path"; import { argv } from "node:process"; import { argument, map, message, object, string } from "@optique/core"; import { run } from "@optique/run"; import { Alg } from "@vscubing/cubing/alg"; import { KPuzzle } from "@vscubing/cubing/kpuzzle"; import { getPuzzleGeometryByName } from "@vscubing/cubing/puzzle-geometry"; import { puzzles } from "@vscubing/cubing/puzzles"; var args = run( object({ puzzleGeometryID: argument(string({ metavar: "PUZZLE" }), { description: message`Puzzle geometry ID` }), alg: map( argument(string({ metavar: "ALG" }), { description: message`Alg` }), Alg.fromString ) }), { programName: basename(argv[1]), description: message`Example: order 3x3x3 "R U R' U R U2' R'"`, help: "option", completion: { mode: "option", name: "plural" }, version: { mode: "option", value: packageVersion } } ); var { puzzleGeometryID, alg } = args; var puzzleLoader = puzzles[puzzleGeometryID]; var kpuzzle = await (async () => { if (puzzleLoader) { return await puzzles[puzzleGeometryID].kpuzzle(); } else { const pg = getPuzzleGeometryByName(puzzleGeometryID, { allMoves: true }); return new KPuzzle(pg.getKPuzzleDefinition(true)); } })(); var order = kpuzzle.algToTransformation(alg).repetitionOrder(); console.log(order); //# sourceMappingURL=order.js.map