@slugbugblue/trax-cli 0.12.1 → 0.14.0
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.
- package/.claude/settings.local.json +8 -0
- package/CHANGELOG.md +12 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/eslint.config.js +24 -0
- package/package.json +7 -18
- package/src/cli.js +246 -106
- package/src/cmds/analyze.js +72 -66
- package/src/cmds/delete.js +35 -43
- package/src/cmds/help.js +54 -57
- package/src/cmds/import-export.js +200 -146
- package/src/cmds/index.js +40 -0
- package/src/cmds/list.js +100 -87
- package/src/cmds/new.js +56 -55
- package/src/cmds/notes.js +20 -18
- package/src/cmds/play-try.js +157 -106
- package/src/cmds/puzzles.js +53 -39
- package/src/cmds/select.js +22 -31
- package/src/cmds/suggest.js +28 -37
- package/src/cmds/undo.js +31 -26
- package/src/cmds/view.js +42 -51
- package/src/utils.js +1 -1
- package/src/version.js +1 -1
- package/xo.config.js +10 -0
- package/src/types.d.ts +0 -33
package/src/cmds/view.js
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* You may obtain a copy of the License at
|
|
6
|
-
*
|
|
7
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
-
*
|
|
9
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
* See the License for the specific language governing permissions and
|
|
13
|
-
* limitations under the License.
|
|
1
|
+
/** CLI view command
|
|
2
|
+
* @copyright 2022-2026
|
|
3
|
+
* @author Chad Transtrum <chad@transtrum.net>
|
|
4
|
+
* @license Apache-2.0
|
|
14
5
|
*/
|
|
15
6
|
|
|
16
|
-
|
|
7
|
+
/** @typedef {import('../cli.js').CLIContext} CLIContext */
|
|
17
8
|
|
|
18
9
|
export const viewCmd = {
|
|
19
10
|
name: 'view',
|
|
@@ -25,41 +16,41 @@ export const viewCmd = {
|
|
|
25
16
|
'Show the current game. Include a move number to see the board as it was at',
|
|
26
17
|
'that move.',
|
|
27
18
|
],
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
19
|
+
/** @param {CLIContext} CLI @param {string} [move] @param {...string} extra */
|
|
20
|
+
fn(CLI, move, ...extra) {
|
|
21
|
+
if (!CLI.GAME?.id) {
|
|
22
|
+
return CLI.error('No active game. Type "new" to start a game.')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (move && move.length > 1 && 'puzzles'.startsWith(move)) {
|
|
26
|
+
return CLI.do('puzzles', 'list', ...extra)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const trax = CLI.TRAX
|
|
30
|
+
|
|
31
|
+
let show = Number.POSITIVE_INFINITY
|
|
32
|
+
if (move && Number(move) >= 0 && Number(move) <= trax.moves.length) {
|
|
33
|
+
show = Number(move)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const game = CLI.GAME
|
|
37
|
+
const players = game.players || ['white', 'black']
|
|
38
|
+
const puzzle = game.puzzle || ''
|
|
39
|
+
const note = game.notes?.at(-1)?.note
|
|
40
|
+
|
|
41
|
+
CLI.out(
|
|
42
|
+
CLI.color('#' + CLI.ID + ' ') +
|
|
43
|
+
CLI.name(trax.rules) +
|
|
44
|
+
' ' +
|
|
45
|
+
CLI.bubble('w' + (trax.turn === 1 ? 'h' : ''), players[0]) +
|
|
46
|
+
CLI.color(' vs ') +
|
|
47
|
+
CLI.bubble('b' + (trax.turn === 2 ? 'h' : ''), players[1]),
|
|
48
|
+
)
|
|
49
|
+
CLI.display(trax, players, undefined, show)
|
|
50
|
+
if (puzzle && (!note || !note.includes(puzzle))) {
|
|
51
|
+
CLI.out(CLI.color('Puzzle ' + puzzle))
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (note) CLI.out(CLI.color.help(note))
|
|
55
|
+
},
|
|
65
56
|
}
|
package/src/utils.js
CHANGED
package/src/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '0.
|
|
2
|
+
export const version = '0.14.0'
|
package/xo.config.js
ADDED
package/src/types.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/** Type information.
|
|
2
|
-
* @copyright 2022-2023
|
|
3
|
-
* @author Chad Transtrum <chad@transtrum.net>
|
|
4
|
-
* @license Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** Colorize is a fancy function for colorizing text. */
|
|
8
|
-
type Colorize = (text: string, defaultColor?: string | number) => string
|
|
9
|
-
|
|
10
|
-
/** Colorer is a little too fancy. Hence the gnarly typescript. */
|
|
11
|
-
type Colorer = {
|
|
12
|
-
(text: string, defaultColor?: string | number): string
|
|
13
|
-
black: Colorize
|
|
14
|
-
command: Colorize
|
|
15
|
-
default: Colorize
|
|
16
|
-
error: Colorize
|
|
17
|
-
fatal: Colorize
|
|
18
|
-
help: Colorize
|
|
19
|
-
id: Colorize
|
|
20
|
-
variable: Colorize
|
|
21
|
-
optional: Colorize
|
|
22
|
-
short: Colorize
|
|
23
|
-
white: Colorize
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** A note with a move number */
|
|
27
|
-
type GameNote = {
|
|
28
|
-
move: number
|
|
29
|
-
note: string
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Notes saved in the game object in the CLI. */
|
|
33
|
-
type GameNotes = GameNote[]
|