cubing 0.61.0 → 0.61.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/bin/chunks/chunk-ZQLNUW2N.js +14 -0
  2. package/dist/bin/chunks/chunk-ZQLNUW2N.js.map +7 -0
  3. package/dist/bin/order.js +46 -42
  4. package/dist/bin/order.js.map +2 -2
  5. package/dist/bin/puzzle-geometry-bin.js +379 -257
  6. package/dist/bin/puzzle-geometry-bin.js.map +3 -3
  7. package/dist/bin/scramble.js +124 -102
  8. package/dist/bin/scramble.js.map +3 -3
  9. package/dist/lib/cubing/{KPattern-CU9Suh1T.d.ts → PuzzleLoader-CkghxdIL.d.ts} +186 -179
  10. package/dist/lib/cubing/alg/index.d.ts +2 -2
  11. package/dist/lib/cubing/bluetooth/index.d.ts +3 -3
  12. package/dist/lib/cubing/bluetooth/index.js +4 -4
  13. package/dist/lib/cubing/{bluetooth-puzzle-gTRbIRyj.d.ts → bluetooth-puzzle-c-_IBAdu.d.ts} +1 -1
  14. package/dist/lib/cubing/chunks/{chunk-ABQAUY7H.js → chunk-557DMXD6.js} +3 -3
  15. package/dist/lib/cubing/chunks/{chunk-RKTO4CAU.js → chunk-7DT3G3FA.js} +2 -2
  16. package/dist/lib/cubing/chunks/{chunk-BUZPONAW.js → chunk-I5QO52OG.js} +2 -2
  17. package/dist/lib/cubing/chunks/{chunk-PVOSBZRD.js → chunk-KZGAQEPN.js} +3 -3
  18. package/dist/lib/cubing/chunks/{chunk-RUSWM2KK.js → chunk-ST4K23C3.js} +2 -2
  19. package/dist/lib/cubing/chunks/{chunk-RUSWM2KK.js.map → chunk-ST4K23C3.js.map} +1 -1
  20. package/dist/lib/cubing/chunks/{chunk-REBGU5ET.js → chunk-T3SF7NHB.js} +2 -2
  21. package/dist/lib/cubing/chunks/{chunk-OJI4YUWF.js → chunk-UMNYMJKD.js} +4 -4
  22. package/dist/lib/cubing/chunks/{chunk-WIZJQ7QS.js → chunk-UZ7SWKN6.js} +15 -15
  23. package/dist/lib/cubing/chunks/{chunk-PSQEELP4.js → chunk-WAYEJXCG.js} +1 -1
  24. package/dist/lib/cubing/chunks/chunk-WAYEJXCG.js.map +7 -0
  25. package/dist/lib/cubing/chunks/{chunk-NX2Q6B7Y.js → chunk-ZKJKRQKY.js} +2 -2
  26. package/dist/lib/cubing/chunks/{chunk-NX2Q6B7Y.js.map → chunk-ZKJKRQKY.js.map} +2 -2
  27. package/dist/lib/cubing/chunks/{inside-PM6546BQ.js → inside-K3VX2AIZ.js} +12 -12
  28. package/dist/lib/cubing/chunks/{puzzles-dynamic-side-events-BOGUHF4Q.js → puzzles-dynamic-side-events-IMYJ533P.js} +1 -1
  29. package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-IMYJ533P.js.map +7 -0
  30. package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-SYC27DSG.js → search-dynamic-sgs-side-events-RIRYKEP5.js} +4 -4
  31. package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-QGGV4PCJ.js → search-dynamic-sgs-unofficial-N4CRUF4Q.js} +4 -4
  32. package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-IE5W637Q.js → search-dynamic-solve-4x4x4-4UB4NMF3.js} +7 -7
  33. package/dist/lib/cubing/chunks/search-worker-entry.js +3 -3
  34. package/dist/lib/cubing/chunks/{twisty-dynamic-3d-LPZQIDD2.js → twisty-dynamic-3d-OCL53BVF.js} +5 -5
  35. package/dist/lib/cubing/{index-CORXpckt.d.ts → index-B_8W-2zR.d.ts} +1 -1
  36. package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
  37. package/dist/lib/cubing/kpuzzle/index.js +1 -1
  38. package/dist/lib/cubing/notation/index.d.ts +1 -1
  39. package/dist/lib/cubing/notation/index.js +3 -3
  40. package/dist/lib/cubing/protocol/index.d.ts +1 -1
  41. package/dist/lib/cubing/protocol/index.js +3 -3
  42. package/dist/lib/cubing/puzzle-geometry/index.d.ts +2 -2
  43. package/dist/lib/cubing/puzzle-geometry/index.js +138 -179
  44. package/dist/lib/cubing/puzzle-geometry/index.js.map +3 -3
  45. package/dist/lib/cubing/puzzles/index.d.ts +1 -1
  46. package/dist/lib/cubing/puzzles/index.js +3 -3
  47. package/dist/lib/cubing/scramble/index.d.ts +2 -2
  48. package/dist/lib/cubing/scramble/index.js +6 -6
  49. package/dist/lib/cubing/search/index.d.ts +3 -3
  50. package/dist/lib/cubing/search/index.js +6 -6
  51. package/dist/lib/cubing/stream/index.d.ts +2 -2
  52. package/dist/lib/cubing/twisty/index.d.ts +2 -2
  53. package/dist/lib/cubing/twisty/index.js +5 -5
  54. package/dist/lib/cubing/twisty/index.js.map +1 -1
  55. package/experimental-json-schema/kpuzzle/KPatternData.schema.json +22 -30
  56. package/experimental-json-schema/kpuzzle/KPuzzleDefinition.schema.json +72 -89
  57. package/experimental-json-schema/kpuzzle/KTransformationData.schema.json +17 -26
  58. package/package.json +54 -100
  59. package/dist/bin/chunks/chunk-J53ID3VX.js +0 -26
  60. package/dist/bin/chunks/chunk-J53ID3VX.js.map +0 -7
  61. package/dist/lib/cubing/chunks/chunk-PSQEELP4.js.map +0 -7
  62. package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-BOGUHF4Q.js.map +0 -7
  63. /package/dist/lib/cubing/chunks/{chunk-ABQAUY7H.js.map → chunk-557DMXD6.js.map} +0 -0
  64. /package/dist/lib/cubing/chunks/{chunk-RKTO4CAU.js.map → chunk-7DT3G3FA.js.map} +0 -0
  65. /package/dist/lib/cubing/chunks/{chunk-BUZPONAW.js.map → chunk-I5QO52OG.js.map} +0 -0
  66. /package/dist/lib/cubing/chunks/{chunk-PVOSBZRD.js.map → chunk-KZGAQEPN.js.map} +0 -0
  67. /package/dist/lib/cubing/chunks/{chunk-REBGU5ET.js.map → chunk-T3SF7NHB.js.map} +0 -0
  68. /package/dist/lib/cubing/chunks/{chunk-OJI4YUWF.js.map → chunk-UMNYMJKD.js.map} +0 -0
  69. /package/dist/lib/cubing/chunks/{chunk-WIZJQ7QS.js.map → chunk-UZ7SWKN6.js.map} +0 -0
  70. /package/dist/lib/cubing/chunks/{inside-PM6546BQ.js.map → inside-K3VX2AIZ.js.map} +0 -0
  71. /package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-SYC27DSG.js.map → search-dynamic-sgs-side-events-RIRYKEP5.js.map} +0 -0
  72. /package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-QGGV4PCJ.js.map → search-dynamic-sgs-unofficial-N4CRUF4Q.js.map} +0 -0
  73. /package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-IE5W637Q.js.map → search-dynamic-solve-4x4x4-4UB4NMF3.js.map} +0 -0
  74. /package/dist/lib/cubing/chunks/{twisty-dynamic-3d-LPZQIDD2.js.map → twisty-dynamic-3d-OCL53BVF.js.map} +0 -0
@@ -1,281 +1,403 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env -S node --
2
+ import {
3
+ packageVersion
4
+ } from "./chunks/chunk-ZQLNUW2N.js";
2
5
 
3
6
  // src/bin/puzzle-geometry-bin.ts
7
+ import { argv } from "node:process";
8
+ import {
9
+ argument,
10
+ constant,
11
+ flag,
12
+ integer,
13
+ map,
14
+ merge,
15
+ message,
16
+ multiple,
17
+ object,
18
+ option,
19
+ optional,
20
+ or,
21
+ string
22
+ } from "@optique/core";
23
+ import { run } from "@optique/run";
24
+ import { Move } from "cubing/alg";
4
25
  import {
5
26
  getPG3DNamedPuzzles,
6
27
  PuzzleGeometry,
7
28
  parsePuzzleDescription
8
29
  } from "cubing/puzzle-geometry";
9
- function asstructured(v) {
10
- if (typeof v === "string") {
11
- return JSON.parse(v);
12
- }
13
- return v;
14
- }
15
- function asboolean(v) {
16
- if (typeof v === "string") {
17
- return v !== "false";
18
- } else {
19
- return !!v;
20
- }
21
- }
22
- function parsePGOptionList(optionlist) {
23
- const options = {};
24
- if (optionlist !== void 0) {
25
- if (optionlist.length % 2 !== 0) {
26
- throw new Error("Odd length in option list?");
27
- }
28
- for (let i = 0; i < optionlist.length; i += 2) {
29
- if (optionlist[i] === "verbose") {
30
- options.verbosity = (options.verbosity ?? 0) + 1;
31
- } else if (optionlist[i] === "quiet") {
32
- options.verbosity = 0;
33
- } else if (optionlist[i] === "allmoves") {
34
- options.allMoves = asboolean(optionlist[i + 1]);
35
- } else if (optionlist[i] === "outerblockmoves") {
36
- options.outerBlockMoves = asboolean(optionlist[i + 1]);
37
- } else if (optionlist[i] === "vertexmoves") {
38
- options.vertexMoves = asboolean(optionlist[i + 1]);
39
- } else if (optionlist[i] === "rotations") {
40
- options.addRotations = asboolean(optionlist[i + 1]);
41
- } else if (optionlist[i] === "cornersets") {
42
- options.includeCornerOrbits = asboolean(optionlist[i + 1]);
43
- } else if (optionlist[i] === "centersets") {
44
- options.includeCenterOrbits = asboolean(optionlist[i + 1]);
45
- } else if (optionlist[i] === "edgesets") {
46
- options.includeEdgeOrbits = asboolean(optionlist[i + 1]);
47
- } else if (optionlist[i] === "omit") {
48
- options.excludeOrbits = optionlist[i + 1];
49
- } else if (optionlist[i] === "graycorners") {
50
- options.grayCorners = asboolean(optionlist[i + 1]);
51
- } else if (optionlist[i] === "graycenters") {
52
- options.grayCenters = asboolean(optionlist[i + 1]);
53
- } else if (optionlist[i] === "grayedges") {
54
- options.grayEdges = asboolean(optionlist[i + 1]);
55
- } else if (optionlist[i] === "movelist") {
56
- options.moveList = asstructured(optionlist[i + 1]);
57
- } else if (optionlist[i] === "killorientation") {
58
- options.fixedOrientation = asboolean(optionlist[i + 1]);
59
- } else if (optionlist[i] === "optimize") {
60
- options.optimizeOrbits = asboolean(optionlist[i + 1]);
61
- } else if (optionlist[i] === "scramble") {
62
- options.scrambleAmount = optionlist[i + 1];
63
- } else if (optionlist[i] === "fix") {
64
- options.fixedPieceType = optionlist[i + 1];
65
- } else if (optionlist[i] === "orientcenters") {
66
- options.orientCenters = asboolean(optionlist[i + 1]);
67
- } else if (optionlist[i] === "puzzleorientation") {
68
- options.puzzleOrientation = asstructured(optionlist[i + 1]);
69
- } else if (optionlist[i] === "puzzleorientations") {
70
- options.puzzleOrientations = asstructured(optionlist[i + 1]);
71
- } else {
72
- throw new Error(
73
- `Bad option while processing option list ${optionlist[i]}`
74
- );
75
- }
76
- }
77
- }
78
- return options;
30
+ import { Path } from "path-class";
31
+ import { PrintableShellCommand } from "printable-shell-command";
32
+ var puzzleList = getPG3DNamedPuzzles();
33
+ function antiBool(optionName, description) {
34
+ return optional(
35
+ map(
36
+ flag(optionName, {
37
+ description
38
+ }),
39
+ (v) => !v
40
+ )
41
+ );
79
42
  }
80
- var dosvg = false;
81
- var doss = false;
82
- var doksolve = false;
83
- var dogap = false;
84
- var domathematica = false;
85
- var docanon = false;
86
- var do3d = false;
87
- if (globalThis.process && process.argv && process.argv.length <= 2) {
88
- console.log(
89
- `Usage: puzzle-geometry [options] [puzzle]
43
+ var subcommandDefaults = {
44
+ commentStyle: constant("hash"),
45
+ forceQuiet: constant(void 0)
46
+ };
47
+ var args = run(
48
+ merge(
49
+ object({
50
+ verbosity: optional(
51
+ or(
52
+ map(multiple(flag("--verbose", "-v")), (v) => v.length),
53
+ map(flag("--quiet", "-q"), () => 0)
54
+ )
55
+ )
56
+ }),
57
+ or(
58
+ object({
59
+ ...subcommandDefaults,
60
+ subcommand: constant("KSolve"),
61
+ subcommandFlag: flag("--ksolve", {
62
+ description: message`Print KSolve (\`.tws\`).`
63
+ })
64
+ }),
65
+ object({
66
+ ...subcommandDefaults,
67
+ subcommand: constant("SVG"),
68
+ subcommandFlag: flag("--svg", {
69
+ description: message`Print SVG. Forces \`--quiet\`.`
70
+ }),
71
+ commentStyle: constant("none"),
72
+ svg3D: optional(
73
+ option("--3d", {
74
+ description: message`Use 3D format for SVG file.`
75
+ })
76
+ ),
77
+ verbosity: constant(0)
78
+ }),
79
+ object({
80
+ ...subcommandDefaults,
81
+ subcommand: constant("GAP"),
82
+ subcommandFlag: flag("--gap", {
83
+ description: message`Print GAP output.`
84
+ })
85
+ }),
86
+ object({
87
+ ...subcommandDefaults,
88
+ subcommand: constant("Mathematica"),
89
+ subcommandFlag: flag("--mathematica", {
90
+ description: message`Print Mathematica output.`
91
+ }),
92
+ commentStyle: constant("Pascal")
93
+ }),
94
+ object({
95
+ ...subcommandDefaults,
96
+ subcommand: constant("Schreier-Sims"),
97
+ subcommandFlag: flag("--ss", {
98
+ description: message`Perform Schrier-Sims calculation.`
99
+ })
100
+ }),
101
+ object({
102
+ ...subcommandDefaults,
103
+ subcommand: constant("Canonical string analysis"),
104
+ subcommandFlag: flag("--canon", {
105
+ description: message`Print canonical string analysis.`
106
+ })
107
+ }),
108
+ object({
109
+ ...subcommandDefaults,
110
+ subcommand: constant("3D"),
111
+ subcommandFlag: flag("--3d", {
112
+ description: message`Print 3D information.`
113
+ })
114
+ })
115
+ ),
116
+ object({
117
+ // This doesn't apply to SVG, but we place it here so that it doesn't print once for each non-SVG subcommand in the help string.
118
+ optimizeOrbits: option("--optimize", {
119
+ description: message`Optimize output (when possible).`
120
+ }),
121
+ addRotations: option("--rotations", {
122
+ description: message`Include full-puzzle rotations as moves.`
123
+ }),
124
+ allMoves: option("--allmoves", {
125
+ description: message`Includes all moves (i.e., slice moves for 3x3x3).`
126
+ }),
127
+ outerBlockMoves: option("--outerblockmoves", {
128
+ description: message`Use outer block moves rather than slice moves.`
129
+ }),
130
+ vertexMoves: option("--vertexmoves", {
131
+ description: message`For tetrahedral puzzles, prefer vertex moves to face moves.`
132
+ }),
133
+ includeCornerOrbits: antiBool(
134
+ "--nocorners",
135
+ message`Ignore all corners.`
136
+ ),
137
+ excludeOrbits: optional(
138
+ map(
139
+ option("--omit", string({ metavar: "COMMA_SEPARATED_ORBITS" }), {
140
+ description: message`Omit orbits.`
141
+ }),
142
+ (s) => s.split(",")
143
+ )
144
+ ),
145
+ includeEdgeOrbits: antiBool("--noedges", message`Ignore all edges.`),
146
+ includeCenterOrbits: antiBool(
147
+ "--nocenters",
148
+ message`Ignore all centers.`
149
+ ),
150
+ grayCorners: option("--graycorners", {
151
+ description: message`Gray corners.`
152
+ }),
153
+ grayEdges: option("--grayedges", { description: message`Gray edges.` }),
154
+ grayCenters: option("--graycenters", {
155
+ description: message`Gray centers.`
156
+ }),
157
+ fixedOrientation: option("--noorientation", {
158
+ description: message`Ignore orientations.`
159
+ }),
160
+ orientCenters: option("--orientcenters", {
161
+ description: message`Give centers an orientation.`
162
+ })
163
+ }),
164
+ optional(
165
+ or(
166
+ object({
167
+ puzzleOrientation: optional(
168
+ map(
169
+ option(
170
+ "--puzzleorientation",
171
+ string({ metavar: "JSON_STRING" }),
172
+ {
173
+ description: message`For 3D formats, give puzzle orientation.`
174
+ }
175
+ ),
176
+ (s) => JSON.parse(s)
177
+ )
178
+ ),
179
+ puzzleOrientations: constant(void 0)
180
+ }),
181
+ object({
182
+ puzzleOrientation: constant(void 0),
183
+ puzzleOrientations: optional(
184
+ map(
185
+ option(
186
+ "--puzzleorientations",
187
+ string({ metavar: "JSON_STRING" }),
188
+ {
189
+ description: message`For 3D formats, give puzzle orientations.`
190
+ }
191
+ ),
192
+ (s) => JSON.parse(s)
193
+ )
194
+ )
195
+ })
196
+ )
197
+ ),
198
+ object({
199
+ fixedPieceType: optional(
200
+ or(
201
+ map(
202
+ flag("--fixcorner", {
203
+ description: message`Auto-select a subset of moves to keep a corner fixed in place.`
204
+ }),
205
+ () => "v"
206
+ ),
207
+ map(
208
+ flag("--fixedge", {
209
+ description: message`Auto-select a subset of moves to keep an edge fixed in place.`
210
+ }),
211
+ () => "e"
212
+ ),
213
+ map(
214
+ flag("--fixcenter", {
215
+ description: message`Auto-select a subset of moves to keep a center fixed in place.`
216
+ }),
217
+ () => "f"
218
+ )
219
+ )
220
+ ),
221
+ // TODO: this doesn't make sense for all subcommands?
222
+ scrambleAmount: optional(
223
+ option("--scramble", integer({ min: 0 }), {
224
+ description: message`Scramble solved position.`
225
+ })
226
+ ),
227
+ moveList: optional(
228
+ map(
229
+ option("--moves", string({ metavar: "COMMA_SEPARATED_MOVES" }), {
230
+ description: message`Restrict moves to this list. Example: \"U2,F,r\").`
231
+ }),
232
+ (s) => s.split(",").map((m) => Move.fromString(m))
233
+ )
234
+ ),
235
+ puzzle: map(
236
+ argument(string({ metavar: "PUZZLE" }), {
237
+ description: message`The puzzle can be given as a geometric description or by name.
238
+ The geometric description starts with one of:
239
+
240
+ - \`c\` (cube),\n
241
+ - \`t\` (tetrahedron),\n
242
+ - \`d\` (dodecahedron),\n
243
+ - \`i\` (icosahedron),\n
244
+ - \`o\` (octahedron),\n
90
245
 
91
- Options:
92
- --ksolve: write ksolve (tws) file
93
- --svg: write SVG (default is flat; --3d makes it 3D)
94
- --gap: write gap
95
- --mathematica: write mathematica
96
- --ss: execute Schrier-Sims calculation
97
- --3d: use 3D format for SVG file
98
- --canon: write canonical string analysis
99
- --rotations: include full-puzzle rotations as moves
100
- --allmoves: includes all moves (i.e., slice moves for 3x3x3)
101
- --outerblockmoves: use outer block moves rather than slice moves
102
- --vertexmoves: for tetrahedral puzzles, prefer vertex moves to face moves
103
- --nocorners: ignore all corners
104
- --noedges: ignore all edges
105
- --nocenters: ignore all centers
106
- --noorientation: ignore orientations
107
- --orientcenters: give centers an orientation
108
- --puzzleorientation: for 3D formats, give puzzle orientation
109
- --moves movenames: restrict moves to this list (e.g, U2,F,r)
110
- --optimize: optimize tws/ksolve/gap output
111
- --scramble: scramble solved position
112
- --fixcorner: choose moves to keep one corner fixed
113
- --fixedge: choose moves to keep one edge fixed
114
- --fixcenter: choose moves to keep one center fixed
115
- --verbose (-v): make verbose
246
+ then a space, then a series of cuts. Each cut begins with one of:
116
247
 
117
- The puzzle can be given as a geometric description or by name.
118
- The geometric description starts with c (cube), t (tetrahedron),
119
- d (dodecahedron), i (icosahedron), or o (octahedron), then a
120
- space, then a series of cuts. Each cut begins with f (for a
121
- cut parallel to faces), v (for a cut perpendicular to a ray
122
- from the center through a corner), or e (for a cut perpendicular
123
- to a ray from the center through an edge) followed by a decimal
124
- number giving a distance, where 1 is the distance between the
125
- center of the puzzle and the center of a face.
248
+ - \`f\` (for a cut parallel to faces),\n
249
+ - \`v\` (for a cut perpendicular to a ray from the center through a corner),\n
250
+ - \`e\` (for a cut perpendicular to a ray from the center through an edge),\n
126
251
 
127
- The puzzle names recognized are 2x2x2 through 13x13x13, 20x20x20,
128
- master skewb, professor skewb, compy cube, helicopter, dino,
129
- little chop, pyramorphix, mastermorphix, pyraminx, Jing pyraminx,
130
- master paramorphix, megaminx, gigaminx, pentultimate, starminx,
131
- starminx 2, pyraminx crystal, chopasaurus, big chop, skewb diamond,
132
- FTO, Christopher's jewel, octastar, Trajber's octahedron, radio chop,
133
- icosamate, Regular Astrominx, Regular Astrominx + Big Chop,
134
- Redicosahedron, Redicosahedron with centers,Icosaminx, and Eitan's star.
252
+ followed by a decimal number giving a distance, where 1 is the distance
253
+ between the center of the puzzle and the center of a face.
135
254
 
255
+ Example description: \`c f 0 v 0.577350269189626 e 0\`. Corresponds to: https://alpha.twizzle.net/explore/?puzzle=2x2x2+%2B+dino+%2B+little+chop
256
+
257
+ The recognized puzzle names are: ${Object.keys(puzzleList).map((p) => JSON.stringify(p)).join(", ")}`
258
+ }),
259
+ (s) => {
260
+ const parsed = parsePuzzleDescription(puzzleList[s] ?? s);
261
+ if (parsed === null) {
262
+ throw new Error("Could not parse puzzle description!");
263
+ }
264
+ return parsed;
265
+ }
266
+ )
267
+ })
268
+ ),
269
+ {
270
+ programName: new Path(argv[1]).basename.path,
271
+ description: message`
136
272
  Examples:
137
- puzzlegeometry --ss 2x2x2
138
- puzzlegeometry --ss --fixcorner 2x2x2
139
- puzzlegeometry --ss --moves U,F2,r 4x4x4
140
- puzzlegeometry --ksolve --optimize --moves U,F,R megaminx
141
- puzzlegeometry --gap --noedges megaminx
142
- `
143
- );
144
- }
145
- if (globalThis.process && process.argv && process.argv.length >= 3) {
146
- let desc;
147
- const puzzleList = getPG3DNamedPuzzles();
148
- let argp = 2;
149
- const optionlist = [];
150
- let showargs = true;
151
- let pascalcomment = false;
152
- while (argp < process.argv.length && process.argv[argp][0] === "-") {
153
- const option = process.argv[argp++];
154
- if (option === "--verbose" || option === "-v") {
155
- optionlist.push("verbose", true);
156
- } else if (option === "--quiet" || option === "-q") {
157
- optionlist.push("quiet", true);
158
- showargs = false;
159
- } else if (option === "--ksolve") {
160
- doksolve = true;
161
- } else if (option === "--svg") {
162
- showargs = false;
163
- optionlist.push("quiet", true);
164
- dosvg = true;
165
- } else if (option === "--gap") {
166
- dogap = true;
167
- } else if (option === "--mathematica") {
168
- domathematica = true;
169
- pascalcomment = true;
170
- } else if (option === "--ss") {
171
- doss = true;
172
- } else if (option === "--3d") {
173
- do3d = true;
174
- } else if (option === "--canon") {
175
- docanon = true;
176
- } else if (option === "--rotations") {
177
- optionlist.push("rotations", true);
178
- } else if (option === "--allmoves") {
179
- optionlist.push("allmoves", true);
180
- } else if (option === "--outerblockmoves") {
181
- optionlist.push("outerblockmoves", true);
182
- } else if (option === "--vertexmoves") {
183
- optionlist.push("vertexmoves", true);
184
- } else if (option === "--nocorners") {
185
- optionlist.push("cornersets", false);
186
- } else if (option === "--noedges") {
187
- optionlist.push("edgesets", false);
188
- } else if (option === "--noorientation") {
189
- optionlist.push("killorientation", true);
190
- } else if (option === "--nocenters") {
191
- optionlist.push("centersets", false);
192
- } else if (option === "--omit") {
193
- optionlist.push("omit", process.argv[argp].split(","));
194
- argp++;
195
- } else if (option === "--moves") {
196
- optionlist.push("movelist", process.argv[argp].split(","));
197
- argp++;
198
- } else if (option === "--optimize") {
199
- optionlist.push("optimize", true);
200
- } else if (option === "--scramble") {
201
- optionlist.push("scramble", 100);
202
- } else if (option === "--fixcorner") {
203
- optionlist.push("fix", "v");
204
- } else if (option === "--fixedge") {
205
- optionlist.push("fix", "e");
206
- } else if (option === "--fixcenter") {
207
- optionlist.push("fix", "f");
208
- } else if (option === "--orientcenters") {
209
- optionlist.push("orientcenters", true);
210
- } else if (option === "--puzzleorientation") {
211
- optionlist.push("puzzleorientation", process.argv[argp]);
212
- argp++;
213
- } else {
214
- throw new Error(`Bad option: ${option}`);
273
+
274
+ puzzle-geometry --ss 2x2x2\n
275
+ puzzle-geometry --ss --fixcorner 2x2x2\n
276
+ puzzle-geometry --ss --moves U,F2,r 4x4x4\n
277
+ puzzle-geometry --ksolve --optimize --moves U,F,R megaminx\n
278
+ puzzle-geometry --gap --noedges megaminx
279
+ `,
280
+ help: "option",
281
+ completion: {
282
+ mode: "option",
283
+ name: "plural"
284
+ },
285
+ version: {
286
+ mode: "option",
287
+ value: packageVersion
215
288
  }
216
289
  }
217
- for (const [name, curDesc] of Object.entries(puzzleList)) {
218
- if (name === process.argv[argp]) {
219
- desc = curDesc;
290
+ );
291
+ if (args.verbosity !== 0) {
292
+ const cmd = () => {
293
+ const [command, ...args2] = argv;
294
+ return new PrintableShellCommand(command, args2).getPrintableCommand({
295
+ argumentLineWrapping: "inline"
296
+ });
297
+ };
298
+ switch (args.commentStyle) {
299
+ case "hash": {
300
+ console.log(`# ${cmd()}`);
220
301
  break;
221
302
  }
222
- }
223
- let puzzleDescription;
224
- if (showargs) {
225
- if (pascalcomment) {
226
- console.log(`(* ${process.argv.join(" ")} *)`);
227
- } else {
228
- console.log(`# ${process.argv.join(" ")}`);
229
- }
230
- }
231
- if (desc !== void 0) {
232
- const parsed = parsePuzzleDescription(desc);
233
- if (parsed === null) {
234
- throw new Error("Could not parse puzzle description!");
303
+ case "none": {
304
+ break;
235
305
  }
236
- puzzleDescription = parsed;
237
- argp++;
238
- } else {
239
- const cuts = [];
240
- const cutarg = argp++;
241
- while (argp + 1 < process.argv.length && process.argv[argp].length === 1) {
242
- cuts.push({
243
- cutType: process.argv[argp],
244
- distance: parseFloat(process.argv[argp + 1])
245
- });
246
- argp += 2;
306
+ case "Pascal": {
307
+ console.log(`(* ${cmd()} *)`);
308
+ break;
247
309
  }
248
- puzzleDescription = {
249
- shape: process.argv[cutarg],
250
- cuts
251
- };
310
+ default:
311
+ throw new Error("Invalid comment style.");
312
+ }
313
+ }
314
+ function buildPuzzleGeometry() {
315
+ const {
316
+ verbosity,
317
+ optimizeOrbits,
318
+ addRotations,
319
+ allMoves,
320
+ outerBlockMoves,
321
+ vertexMoves,
322
+ includeCornerOrbits,
323
+ includeCenterOrbits,
324
+ includeEdgeOrbits,
325
+ excludeOrbits,
326
+ grayCorners,
327
+ grayEdges,
328
+ grayCenters,
329
+ fixedOrientation,
330
+ orientCenters,
331
+ puzzleOrientation,
332
+ puzzleOrientations,
333
+ fixedPieceType,
334
+ scrambleAmount,
335
+ moveList
336
+ } = args;
337
+ const options = {
338
+ verbosity,
339
+ optimizeOrbits,
340
+ addRotations,
341
+ allMoves,
342
+ outerBlockMoves,
343
+ vertexMoves,
344
+ includeCornerOrbits,
345
+ includeCenterOrbits,
346
+ includeEdgeOrbits,
347
+ excludeOrbits,
348
+ grayCorners,
349
+ grayEdges,
350
+ grayCenters,
351
+ fixedOrientation,
352
+ orientCenters,
353
+ puzzleOrientation,
354
+ puzzleOrientations,
355
+ fixedPieceType,
356
+ scrambleAmount,
357
+ moveList
358
+ };
359
+ const puzzleGeometry = new PuzzleGeometry(args.puzzle, options);
360
+ puzzleGeometry.allstickers();
361
+ puzzleGeometry.genperms();
362
+ return puzzleGeometry;
363
+ }
364
+ switch (args.subcommand) {
365
+ case "KSolve": {
366
+ console.log(buildPuzzleGeometry().writeksolve());
367
+ break;
368
+ }
369
+ case "SVG": {
370
+ console.log(
371
+ buildPuzzleGeometry().generatesvg(
372
+ void 0,
373
+ void 0,
374
+ void 0,
375
+ args.svg3D
376
+ )
377
+ );
378
+ break;
379
+ }
380
+ case "GAP": {
381
+ console.log(buildPuzzleGeometry().writegap());
382
+ break;
252
383
  }
253
- const options = parsePGOptionList(optionlist);
254
- const pg = new PuzzleGeometry(puzzleDescription, options);
255
- pg.allstickers();
256
- pg.genperms();
257
- if (argp < process.argv.length) {
258
- throw new Error("Unprocessed content at end of command line");
384
+ case "Mathematica": {
385
+ console.log(buildPuzzleGeometry().writemathematica());
386
+ break;
259
387
  }
260
- if (dogap) {
261
- console.log(pg.writegap());
262
- } else if (domathematica) {
263
- console.log(pg.writemathematica());
264
- } else if (doksolve) {
265
- console.log(pg.writeksolve());
266
- } else if (dosvg) {
267
- console.log(pg.generatesvg(void 0, void 0, void 0, do3d));
268
- } else if (do3d) {
269
- console.log(JSON.stringify(pg.get3d()));
270
- } else if (doss) {
271
- pg.writeSchreierSims(console.log);
272
- } else if (docanon) {
273
- pg.showcanon((_) => console.log(_));
388
+ case "Schreier-Sims": {
389
+ buildPuzzleGeometry().writeSchreierSims(console.log);
390
+ break;
274
391
  }
392
+ case "Canonical string analysis": {
393
+ buildPuzzleGeometry().showcanon(console.log);
394
+ break;
395
+ }
396
+ case "3D": {
397
+ console.log(JSON.stringify(buildPuzzleGeometry().get3d(), null, " "));
398
+ break;
399
+ }
400
+ default:
401
+ throw new Error("Invalid subcommand.");
275
402
  }
276
- export {
277
- asboolean,
278
- asstructured,
279
- parsePGOptionList
280
- };
281
403
  //# sourceMappingURL=puzzle-geometry-bin.js.map